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

Edit subcommand markers #5780

Closed
2 tasks done
mondeja opened this issue Oct 17, 2024 · 1 comment
Closed
2 tasks done

Edit subcommand markers #5780

mondeja opened this issue Oct 17, 2024 · 1 comment
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations

Comments

@mondeja
Copy link

mondeja commented Oct 17, 2024

Please complete the following tasks

Clap Version

4.5.20

Describe your use case

Currently, subcommand markers are generated as <> for required subcommands or [] for optional ones.

I would like to edit them. This would make transitions from other tools or rewritings much more easy.

For example, in Python by default are presented as {cmd1,cmd2...}, see https://docs.python.org/es/3/library/argparse.html#argparse.ArgumentParser.add_subparsers at:

metavar - string presenting available subcommands in help; by default it is None and presents subcommands in form {cmd1, cmd2, ..}

Describe the solution you'd like

I would like a to call a method like subcommand_markers("{", "}"). For example:

Command::new("foo")
    .subcommand_value_name("run,install")
    .subcommand_markers("{", "}")

Running foo --help:

Usage: foo {run,install}

...

Alternatives, if applicable

No response

Additional Context

No response

@mondeja mondeja added the C-enhancement Category: Raise on the bar on expectations label Oct 17, 2024
@epage epage added the A-help Area: documentation, including docs.rs, readme, examples, etc... label Oct 18, 2024
@epage
Copy link
Member

epage commented Oct 18, 2024

In clap, we try to balance a couple of factors

  • Encourage people towards best / common practices while this goes off into less common practices
  • Be careful of our built-in configurability because extending the API comes at the cost of build-times / binary size and the larger the API is, the harder it is for users to find features, making new features reduce the value of every feature of clap

We are interested in decoupling formatting and maybe that would be a way for you to provide a custom skin to handle these different formats. We are tracking this in #2914 and closing in favor of that.

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

No branches or pull requests

2 participants