-
Notifications
You must be signed in to change notification settings - Fork 316
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
Migrate cli implementation from clap to structopt #8027
Migrate cli implementation from clap to structopt #8027
Conversation
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Removed all the clap_app macro invocations of clap and converted the options into structopt structures. The remaining work related to consuming the Structure returned by structopt will be taken into a separate PR. |
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.
A few changes to make, but overall this looks good! I think with this we can remove the feature flag for a structopt CLI, since that's now the only choice.
components/hab/src/cli.rs
Outdated
"Export either the 'public' or 'secret' key. The 'secret' key is the origin private key") | ||
(arg: arg_cache_key_path()) | ||
) | ||
(subcommand: OritinKeyExport::clap().aliases(&["e", "ex", "exp", "expo", "expor"])) |
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.
Spelling error on OritinKeyExport
components/hab/src/cli.rs
Outdated
(subcommand: alias_term) | ||
(after_help: AFTER_HELP) | ||
) | ||
Options::clap() |
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.
Is this not the same as Hab::clap()
above?
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.
Yup, here is the updated code.
pub fn get(feature_flags: FeatureFlag) -> App<'static, 'static> {
if feature_flags.contains(FeatureFlag::STRUCTOPT_CLI) {
return Hab::clap();
}
Options::clap()
}
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.
Originally, when we were first rolling out structopt
to represent parts of the CLI, we hid it behind a feature flag so users could opt in and give feedback, but if anything went wrong, there was an "escape hatch".
Now, however, the CLI is only going to be implemented using structopt
. In that case, it seems that Hab::clap()
and Options::clap()
are going to be the same. Thus, Options
is basically a duplicate of Hab
, which means we don't need Options
at all. It furthermore implies that we can remove the STRUCTOPT_CLI
feature flag altogether.
Are there meaningful differences between Hab
and Options
, or can the latter be removed?
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.
I see some aliases are being explicitly set on certain subcommands, which are not present in Hab::clap() part, and also see some settings are being set settings = &[AppSettings::ArgRequiredElseHelp, AppSettings::SubcommandRequiredElseHelp]
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
Signed-off-by: Phani Sajja <[email protected]>
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.
I have one comment, but otherwise I think this looks good. Thanks for tackling this!
components/hab/src/cli/hab.rs
Outdated
use self::{bldr::{ChannelCreate, | ||
ChannelDemote, | ||
ChannelDestroy, | ||
ChannelList, | ||
ChannelPromote, | ||
ConfigOptChannelCreate, | ||
ConfigOptChannelDemote, | ||
ConfigOptChannelDestroy, | ||
ConfigOptChannelList, | ||
ConfigOptChannelPromote, | ||
ConfigOptJobCancel, | ||
ConfigOptJobDemote, | ||
ConfigOptJobPromote, | ||
ConfigOptJobStart, | ||
ConfigOptJobStatus, | ||
JobCancel, | ||
JobDemote, | ||
JobPromote, | ||
JobStart, | ||
JobStatus}, |
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.
While I generally dislike *
imports as a rule, I think it could be helpful for the use
statements that we've got in this corner of the code, simply because of the sheer volume of imports, as well as the fact that many of those imports are auto-generated ConfigOpt
ones, which tends to make things look a bit confusing.
So, this highlighted code could be collapsed to use self::bldr::*
, with similar replacements for the other module declarations, both in this file and in others that this PR is touching.
What do you think?
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.
Agree in this case!
Signed-off-by: Phani Sajja <[email protected]>
#7866
Removes the clap parsing logic and implements the struct opt cli implementations.