Parse booleans from CLI flags

This commit is contained in:
seanomik 2022-06-20 23:15:14 -04:00 committed by SeanOMik
parent 25bf4db796
commit 507b0e0594
Signed by: SeanOMik
GPG Key ID: 568F326C7EB33ACB
2 changed files with 7 additions and 12 deletions

View File

@ -46,10 +46,14 @@ impl Provider for CliProvider {
// TODO: Parse _args as booleans // TODO: Parse _args as booleans
let (_args, argv) = argmap::parse(args.iter()); let (_args, argv) = argmap::parse(args.iter());
let mut dict = Dict::new();
let mut tree = ArgumentTree::new(); let mut tree = ArgumentTree::new();
for (key, vals) in argv { for (key, vals) in argv {
let len = vals.len(); let len = vals.len();
if len == 0 { if len == 0 {
// This is usually where booleans are given (use_cache, replace_torrents, etc.)
dict.insert(key, Value::Bool(Tag::Default, true));
continue; continue;
} }
@ -71,7 +75,9 @@ impl Provider for CliProvider {
tree.insert(&mut key_iter, val); tree.insert(&mut key_iter, val);
} }
Ok(tree.to_dict()) dict.append(&mut tree.to_dict());
Ok(dict)
} }
match &self.profile { match &self.profile {

View File

@ -74,18 +74,7 @@ async fn main() {
for torrent_path in torrent_files.iter() { for torrent_path in torrent_files.iter() {
let torrent = Torrent::read_from_file(torrent_path).unwrap(); let torrent = Torrent::read_from_file(torrent_path).unwrap();
// To check for private torrents
/* if let Some(extra_info) = &torrent.extra_info_fields {
if let Some(BencodeElem::Integer(is_private)) = extra_info.get("private") {
if *is_private == 1 {
}
}
} */
let torrent = Arc::new(torrent); let torrent = Arc::new(torrent);
//info!("{}:", torrent.name);
for indexer in indexers.iter() { for indexer in indexers.iter() {
let mut indexer = Arc::clone(indexer); let mut indexer = Arc::clone(indexer);