mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-06-21 12:24:17 +08:00
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.
29 lines
647 B
Rust
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);
|
|
}
|
|
}
|