-
Notifications
You must be signed in to change notification settings - Fork 5
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
Used pattern matching to match subcommands #4
Conversation
The following things can be improved in this PR, need your suggestions
|
clap-rs/clap#1104 this issue seems to be stalled for a few years now, so i would not count on it ! It's nice if it finally lands, but in the meantime i'd like to keep the enums and find a workaround. |
Actually, that issue was the first time they discussed it, they have added an example about the use of enums here. Our current implementation is good too, so I think we keep it this way for now. |
Can you explain a bit more the issue you have with matching the commands with the enums variants ? |
I already used drang for converting the enums variants to string. Maybe you just need to import asRefStr in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments. Also please run cargo fmt
on your PRs
src/arguments.rs
Outdated
@@ -64,9 +65,11 @@ App::new("Drogue Command Line Tool") | |||
.about("Allows to manage drogue apps and devices in a drogue-cloud instance") | |||
.arg(config_file_arg) | |||
.arg(url_arg) | |||
.setting(AppSettings::SubcommandRequiredElseHelp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not adding : setting(AppSettings::SubcommandRequiredElseHelp)
to the App
object at the root level instead of adding it to every subcommand ?
(maybe it does not works recursively, but i think it does at it is not mentionned in the documentation)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried this but it doesn't work recursively.
fa4ef28
to
291c5a0
Compare
Added argsElseHelp flag formatted code Fixed typo
Fixes #3
required(true)
is added toapp_id_arg
to delegate error handling to clap.