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

Doing long-only options is awkward #18

Closed
jordansissel opened this issue Oct 5, 2011 · 6 comments
Closed

Doing long-only options is awkward #18

jordansissel opened this issue Oct 5, 2011 · 6 comments

Comments

@jordansissel
Copy link

Best way I found to do long-only options in commander is this hack:

program.option(", --some-option <value>", ...)

The hack here is leading with a comma, so the Option object properly splits and sees --some-option is a long flag. Without the leading ", " it will see --some-option as the short flag and as the long one - kind of stuck my brain for a minute when I saw it first ;)

Thoughts?

@tj
Copy link
Owner

tj commented Oct 5, 2011

why do you want long only? just pick some lame short char :)

@jordansissel
Copy link
Author

Two reasons, one certainly more valid and common than the other:

  • Long flag options are very explicit and readable. Short one require humans to look up "What does -Z mean?"
  • I've had programs in the past that had so many flags you'd run out of letters of the alphabet (caps included) several times over to cover all the flags (such programs used flags instead of config files, there were hundreds of flags)

In the first case (long flags are readable) I would prefer enforcing "You will use the long option because it's readable" at the code level by not exposing any short flags.

@jordansissel
Copy link
Author

If the hack above (leading with comma, no short flag) stops working suddenly in the future due to your changes, no worries - I'll just label all my current flags starting at -A going through the alphabet, I suppose, so I won't pretend that such a hack is a supported thing just yet ;)

@tj
Copy link
Owner

tj commented Oct 5, 2011

cool well im sure we can make it optional easily

@jordansissel
Copy link
Author

I can send you a patch if you don't have time/energy. Lemme know :)

@felixge
Copy link
Contributor

felixge commented Oct 29, 2011

+1, I would also love long-only options. Use case: --version and -v, --verbose.

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

3 participants