redox/src/bin/list_recipes.rs
Josh Megnauth 0ae1974a03
Move struct Package to redox-pkg
This deduplicates code as well as forces names to be sanitized. The API
for both redox-pkg and cookbook need some reimagining due to the
reshuffling, but this patch is not concerned with that as yet.
2025-07-05 07:48:28 -04:00

29 lines
647 B
Rust

use std::process::exit;
use pkg::recipes;
fn main() {
let print_short = std::env::args()
.nth(1)
.map_or(false, |a| a == "-s" || a == "--short");
let result = recipes::list("");
if result.is_empty() {
eprintln!("recipes not found");
exit(1);
} else {
for path in result {
let Some(file_name) = path.file_name() else {
continue;
};
if print_short {
println!("{}", file_name.to_string_lossy());
} else {
println!("{}", path.to_string_lossy());
}
}
exit(0);
}
}