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

Option repetition (mostly for verbosity 'levels') ? #38

Open
kevinquinnyo opened this issue Sep 17, 2014 · 6 comments
Open

Option repetition (mostly for verbosity 'levels') ? #38

kevinquinnyo opened this issue Sep 17, 2014 · 6 comments

Comments

@kevinquinnyo
Copy link

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.

@kevinquinnyo
Copy link
Author

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.

@stratease
Copy link

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.

@nategood
Copy link
Owner

No easy support for it currently, but agree it is a worth while feature. Labeling as such.

@kevinquinnyo
Copy link
Author

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.

@c9s
Copy link

c9s commented Apr 24, 2015

This was implemented in GetOptionKit. FYI: https://github.com/c9s/GetOptionKit/wiki/Defining-Options#incremental-flag

@NeoVance
Copy link
Contributor

PR #63 Closes this @nategood

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants