diff --git a/Cargo.lock b/Cargo.lock index bb1ded8..522f387 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "config" -version = "0.0.1" +version = "0.1.0" dependencies = [ "toml", ] diff --git a/Cargo.toml b/Cargo.toml index 05b5538..5d6de47 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "config" -version = "0.0.2" +version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/main.rs b/src/main.rs index a37e0ba..624a159 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ use toml::Value; mod error; -pub const VERSION: &str = "0.0.2"; +pub const VERSION: &str = "0.1.0"; fn main() -> Result<(), Box>{ let home_dir = var("HOME").unwrap(); @@ -58,7 +58,19 @@ fn main() -> Result<(), Box>{ } if list { - for key in config.keys() { + let mut section = config; + if args.len() > 1 { + let mut args = args.clone(); + args.remove(0); + for arg in args { + let i_sub = section.get(arg.as_str()); + if i_sub.is_none() { return Ok(()); } + let sub = i_sub.unwrap().as_table(); + if sub.is_none() { return Ok(()); } + section = sub.unwrap(); + } + } + for key in section.keys() { println!("{}", key); } return Ok(()); @@ -145,7 +157,7 @@ fn main() -> Result<(), Box>{ fn help_text() { println!("config v{}", VERSION); - println!("Valerie Wolfe "); println!("A configuration manager written in Rust.\n"); println!("USAGE:"); println!("\tconfig NAME\n");