From 507b0e05941698c777b827474e511f76f84470fb Mon Sep 17 00:00:00 2001 From: seanomik Date: Mon, 20 Jun 2022 23:15:14 -0400 Subject: [PATCH] Parse booleans from CLI flags --- src/config/cli_provider.rs | 8 +++++++- src/main.rs | 11 ----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/config/cli_provider.rs b/src/config/cli_provider.rs index bc043ac..d2f23f4 100644 --- a/src/config/cli_provider.rs +++ b/src/config/cli_provider.rs @@ -46,10 +46,14 @@ impl Provider for CliProvider { // TODO: Parse _args as booleans let (_args, argv) = argmap::parse(args.iter()); + let mut dict = Dict::new(); let mut tree = ArgumentTree::new(); for (key, vals) in argv { let len = vals.len(); if len == 0 { + // This is usually where booleans are given (use_cache, replace_torrents, etc.) + dict.insert(key, Value::Bool(Tag::Default, true)); + continue; } @@ -71,7 +75,9 @@ impl Provider for CliProvider { tree.insert(&mut key_iter, val); } - Ok(tree.to_dict()) + dict.append(&mut tree.to_dict()); + + Ok(dict) } match &self.profile { diff --git a/src/main.rs b/src/main.rs index a71caa7..b7027cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -74,18 +74,7 @@ async fn main() { for torrent_path in torrent_files.iter() { 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); - //info!("{}:", torrent.name); for indexer in indexers.iter() { let mut indexer = Arc::clone(indexer);