-
Notifications
You must be signed in to change notification settings - Fork 102
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
Indicate which arguments are required #85
Comments
I'm interested in implementing this feature to give something back. Did you have any ideas about how you would like this implemented? Would it be something like: desc 'Some argument'
arg_name 'some_arg'
required 'You must specify some argument'
flag :arg The message could be optional. In the help text might it automatically append Should GLI handle someone not providing a required flag/switch? What behaviour would you like then? Display the help for the command perhaps? |
Currently, flag arguments are always required even though OptionParser doesn't really require that. I was mostly referring to command arguments, e.g. desc 'Complete a task'
arg_name 'task_id'
command :complete do |c|
end It gets tricky cause GLI just gives an Array to the desc 'Complete a task'
# arg name is "task_id" and exactly one is required
args :task_id => :required
command :complete do |c|
end desc 'Complete a task'
# arg name is "task_id" and one or more are accepted
args :task_id => [:required,:multiple]
command :complete do |c|
end desc 'Complete a task'
# two args: task_id, which is required and message, which is optional.
# Would then expect to see "todo complete task_id [message]" in the help text
args :task_id => :required, :message => :optional
command :complete do |c|
end I suppose a minimum viable feature that helps for most cases could be just
That simply requires that at least one arg is provided. That might cover a lot of cases and avoid dealing with the crazy multiple arguments thing. If you do feel l like working on this (thanks by the way!), Use the |
Great. That gives me a good idea of what you're looking for. |
Hi, did someone had time to make some progress on this one? I'm looking forward to the :multiple flag: to be able to do thing like It's not yet possible unless I'm missed something. If nobody has time, I may be able to provide some. ++ |
@sathlan you can currently do what you want via:
And then a command-line invocation like
will give you the value I know this isn't exactly what you want, but it's a decent workaround. |
Might be nice to indicate which arguments are required
The text was updated successfully, but these errors were encountered: