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

optional args support #8

Open
nanobowers opened this issue Jan 20, 2020 · 0 comments
Open

optional args support #8

nanobowers opened this issue Jan 20, 2020 · 0 comments

Comments

@nanobowers
Copy link
Owner

Would be nice to support an opt that can be given with/without arguments. Without arguments (or defaults), it would take on flag-like behavior.

opt :abc, "flag-or-str", :type => :stringflag
cmd             # opts[:log] == nil
cmd --abc       # opts[:log] == true
cmd --abc hello # opts[:log] == "hello"

One such case would be a "log" option that couldtake a default value (output.log) if enabled without an argument, but could have that value overridden
examples:

opt :log, "maybe-a-log", :type => :stringflag, :default => "output.log"
cmd                   # opts[:log] == nil
cmd --log             # opts[:log] == "output.log"
cmd --log another.log # opts[:log] == "another.log"

currently all options in Optimist are either flags (taking no args) or are of a type that take args. Supporting this feature may be difficult w/ the current codebase especially when taking into account how defaults should be handled, if no- args should be handled, what to do with multi and/or array types.

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

1 participant