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

[Feature request] Printing help when using a subcommand without additional arguments #384

Open
leonav-unizar opened this issue Nov 10, 2024 · 0 comments

Comments

@leonav-unizar
Copy link

leonav-unizar commented Nov 10, 2024

Use case

When writing a subcommand that requires further arguments that were not supplied, print a help message for the subcommand.

Example

argparse::ArgumentParser program("test");

argparse::ArgumentParser process_subcommand("subcom");
process_subcommand.add_description("One subcommand");
process_subcommand.show_help_on_failure(); // EXAMPLE function to be added

process_command.add_argument("action")
  .help("Action to perform")
  .choices("A", "B");

Then, when running the command, adding the --help would have the same effect as it wasn't there:

# With the help flag
./test subcom --help
Usage: test subcom [--help] [--version] [--action]
# Without the help flag
./test subcom
action: 1 argument(s) expected. 0 provided.
Usage: test subcom [--help] [--version] [--action]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant