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

How do I create short option -1? #31

Open
vi opened this issue Oct 22, 2022 · 1 comment
Open

How do I create short option -1? #31

vi opened this issue Oct 22, 2022 · 1 comment

Comments

@vi
Copy link

vi commented Oct 22, 2022

It says error: invalid flags syntax, long option is required for '-' if I try to do

   let flags = xflags::parse_or_exit! {
        /// Serve only one upload
        optional -1,--once
    };
@matklad
Copy link
Owner

matklad commented Oct 22, 2022

I am inclined to explicitly not support this:

  • this complicates macro parsing, as 1 is not an ident
  • fuchsia guidelines, which we mostly follow, explictly tells

Do not create numeric options, such as -1 or -2. E.g. rather than having -1 mean to do something once, add a --once option. If a numeric value is needed, make a keyed option, like --repeat .

We should provide a nicer error message here though!

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

2 participants