Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clap_mangen does not write the arg information in the subcommand #4818

Closed
2 tasks done
eatradish opened this issue Apr 1, 2023 · 2 comments
Closed
2 tasks done

clap_mangen does not write the arg information in the subcommand #4818

eatradish opened this issue Apr 1, 2023 · 2 comments
Labels
C-bug Category: Updating dependencies

Comments

@eatradish
Copy link

eatradish commented Apr 1, 2023

Please complete the following tasks

Rust Version

rustc 1.68.2 (9eb3afe9e 2023-03-27)

Clap Version

clap 4.2.1

Minimal reproducible code

fn main() -> std::io::Result<()> {
    let cmd = command_builder();

    let man = clap_mangen::Man::new(cmd);
    let mut buffer: Vec<u8> = Default::default();
    man.render(&mut buffer)?;

    let man_dir = std::path::PathBuf::from(
        std::env::var_os("CARGO_MANIFEST_DIR").ok_or(std::io::ErrorKind::NotFound)?,
    )
    .join("man");

    if !man_dir.is_dir() {
        std::fs::create_dir_all(&man_dir)?;
    }

    std::fs::write(man_dir.join("oma.1"), buffer)?;

    Ok(())
}

fn command_builder() {
command!()
        .subcommand(
            Command::new("install")
                .about("Install Package")
                .arg(&pkgs)
                .arg(
                    Arg::new("install_dbg")
                        .alias("dbg")
                        .long("install-dbg")
                        .help("Install package(s) debug symbol")
                        .requires("packages")
                        .action(ArgAction::SetTrue)
                )
                .arg(
                    Arg::new("reinstall")
                        .long("reinstall")
                        .help("Reinstall package(s)")
                        .requires("packages")
                        .action(ArgAction::SetTrue),
                )
        )
}

Steps to reproduce the bug with the above code

  1. cargo build --release
  2. Check SRCDIR/man/oma.1 file
  3. See result, like:
...
SUBCOMMANDS
       oma-install(1)
              Install Package

       oma-upgrade(1)
              Update Package

...

Does not have argument help information.

Actual Behaviour

No information is written to the argment in the subcommand

Expected Behaviour

written to the argment in the subcommand

Additional Context

No response

Debug Output

No response

@eatradish eatradish added the C-bug Category: Updating dependencies label Apr 1, 2023
@eatradish eatradish changed the title clap_mangen does not write the parameter information in the subcommand clap_mangen does not write the arg information in the subcommand Apr 1, 2023
@epage
Copy link
Member

epage commented Apr 3, 2023

No information is written to the argment in the subcommand

What do you mean by "argument help information"?

Are you expecting the one manpage to service all subcommands? Currently, we only support generating man pages for the model where the is one man page per subcommand.

See also

@eatradish
Copy link
Author

Looks like your advice solved my problem, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Updating dependencies
Projects
None yet
Development

No branches or pull requests

2 participants