--list-packages argument

parent d6f2936a
...@@ -15,6 +15,7 @@ fn main() { ...@@ -15,6 +15,7 @@ fn main() {
let mut configs = vec![]; let mut configs = vec![];
let mut cookbook = None; let mut cookbook = None;
let mut list_packages = false;
for arg in env::args().skip(1) { for arg in env::args().skip(1) {
if arg.starts_with("--cookbook=") { if arg.starts_with("--cookbook=") {
let path = arg.splitn(2, "--cookbook=").nth(1).unwrap().to_string(); let path = arg.splitn(2, "--cookbook=").nth(1).unwrap().to_string();
...@@ -27,6 +28,11 @@ fn main() { ...@@ -27,6 +28,11 @@ fn main() {
continue; continue;
} }
if arg == "--list-packages" {
list_packages = true;
continue;
}
match File::open(&arg) { match File::open(&arg) {
Ok(mut config_file) => { Ok(mut config_file) => {
let mut config_data = String::new(); let mut config_data = String::new();
...@@ -72,7 +78,11 @@ fn main() { ...@@ -72,7 +78,11 @@ fn main() {
} }
for config in configs { for config in configs {
if let Err(err) = redox_installer::install(config, cookbook.as_ref().map(String::as_ref)) { if list_packages {
for (packagename, _package) in &config.packages {
println!("{}", packagename);
}
} else if let Err(err) = redox_installer::install(config, cookbook.as_ref().map(String::as_ref)) {
writeln!(stderr, "installer: failed to install: {}", err).unwrap(); writeln!(stderr, "installer: failed to install: {}", err).unwrap();
process::exit(1); process::exit(1);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment