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

add argument support #25

Merged
merged 13 commits into from
Dec 17, 2020
Merged

add argument support #25

merged 13 commits into from
Dec 17, 2020

Conversation

skaldesh
Copy link
Member

@skaldesh skaldesh commented Sep 29, 2020

this adds argument support in a similar fashion as flags.
The following rules are implemented:

  • arguments must be supplied in the exact same order as they have been registered
  • arguments are now typed, just like flags (String, Int, Bool, ...)
  • arguments can be optional and can then have a default value
  • list arguments are possible, where the minimum and maximum number of elements can be specified
    Example: rm path [paths...] which has list argument path with min = 1
  • it is not allowed to register an optional argument before a mandatory one
  • it is not allowed to register more than one list argument, which must be at the end
  • so only this order is possible: cmd arg1 arg2 [arg3] [arg4] [arg5...]

We make a small breaking change here and remove the old AllowArgs and refactor the Args on the context to use the new interface.

closes #3

@skaldesh skaldesh mentioned this pull request Oct 5, 2020
@skaldesh skaldesh changed the title add argument support WIP: add argument support Oct 6, 2020
@skaldesh skaldesh marked this pull request as draft October 6, 2020 15:48
@skaldesh skaldesh marked this pull request as ready for review October 7, 2020 15:47
@skaldesh skaldesh requested a review from r0l1 October 7, 2020 15:47
@skaldesh skaldesh changed the title WIP: add argument support add argument support Oct 7, 2020
@skaldesh
Copy link
Member Author

An additional nice feature added here is, that if no usage message is defined, one is composed automatically from all the registered flags and args

Copy link
Member

@r0l1 r0l1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@r0l1 r0l1 merged commit 80ac6f7 into master Dec 17, 2020
@r0l1 r0l1 deleted the f3-args branch December 17, 2020 21:27
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

Successfully merging this pull request may close these issues.

Improve Args parsing
2 participants