commando
commando copied to clipboard
Option repetition (mostly for verbosity 'levels') ?
Is there a clean way to implement this using the existing code? Or would it need to be a new feature?
Think ssh -v[vvvvvv...] (incrementing levels of verbosity if the option is repeated)
Note that with ssh
, it functions the same with: ssh -v -v -v -v example.com
and ssh -vvvv example.com
I don't recall ever seeing this type of "option repetition" used with anything other than verbosity levels, and I'm not sure if that's even a GNU utility psuedo-standard, or if it's just specific to ssh
and a few other oddball utilities, but it is handy. I'd actually like to use that for a project I'm building, using your Commando library that wraps around ssh
, and would like to provide the same -v[vvv...] functionality if possible. Ideas?
I love your work on this by the way -- great library.
Just wanted to clarify how I imagined this might look like:
$options->option('v')
->describedAs(Verbosity. Add more for additional verbosity - ie: -vvv')
->repeatable();
I'm thinking all it would have to do is set a count of how many v's were supplied. Then the user of your library can do whatever they need to, given that count? I haven't dug through the code too much yet, so I'm not sure if it would require a lot of refactor to implement something like this or not.
I agree, that's a useful feature I've desired as well. I've seen it used in other libs, I believe maybe mongo or some other popular cli that escapes me at the moment.
No easy support for it currently, but agree it is a worth while feature. Labeling as such.
Cool! Hey I was inspired and bored, so I made my own (more of a rough draft) heavily inspired by your library.
https://github.com/kevinquinnyo/Optopus
In fact I downright stole your method chaining slickness. This one is missing a lot of cool things you have, but it does have the framework in place for the repeats()
method as well as the --
end-of-options support that I think is also lacking in yours. Maybe it will inspire you? I'm thinking I might be better off just cloning yours and making a pull request for some feature branches since I don't want to re-invent the wheel here.
This was implemented in GetOptionKit. FYI: https://github.com/c9s/GetOptionKit/wiki/Defining-Options#incremental-flag
PR #63 Closes this @nategood