Skip to content

Commit

Permalink
Merge pull request #5093 from sylvestre/fix-man-coreutils
Browse files Browse the repository at this point in the history
Improve the coreutils manpage
  • Loading branch information
cakebaker authored Jul 18, 2023
2 parents 0f6058a + 83c8517 commit cf29f3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ pub fn main() {
let mut mf = File::create(Path::new(&out_dir).join("uutils_map.rs")).unwrap();

mf.write_all(
"type UtilityMap<T> = phf::Map<&'static str, (fn(T) -> i32, fn() -> Command)>;\n\
"type UtilityMap<T> = phf::OrderedMap<&'static str, (fn(T) -> i32, fn() -> Command)>;\n\
\n\
fn util_map<T: uucore::Args>() -> UtilityMap<T> {\n"
.as_bytes(),
)
.unwrap();

let mut phf_map = phf_codegen::Map::<&str>::new();
let mut phf_map = phf_codegen::OrderedMap::<&str>::new();
for krate in &crates {
let map_value = format!("({krate}::uumain, {krate}::uu_app)");
match krate.as_ref() {
Expand Down
11 changes: 9 additions & 2 deletions src/bin/coreutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,15 @@ fn gen_manpage<T: uucore::Args>(

fn gen_coreutils_app<T: uucore::Args>(util_map: &UtilityMap<T>) -> Command {
let mut command = Command::new("coreutils");
for (_, (_, sub_app)) in util_map {
command = command.subcommand(sub_app());
for (name, (_, sub_app)) in util_map {
// Recreate a small subcommand with only the relevant info
// (name & short description)
let about = sub_app()
.get_about()
.expect("Could not get the 'about'")
.to_string();
let sub_app = Command::new(name).about(about);
command = command.subcommand(sub_app);
}
command
}

0 comments on commit cf29f3f

Please sign in to comment.