Skip to content

Commit

Permalink
move context arg back at the root level.
Browse files Browse the repository at this point in the history
Not the nicest solution but fixes #70 for now until we move to clap v3
  • Loading branch information
jbtrystram committed May 25, 2021
1 parent ad49628 commit a97cc8e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "drg"
version = "0.5.0"
version = "0.5.1"
authors = ["Jean-Baptiste Trystram <jbtrystram@redhat.com>"]
edition = "2018"
license = "Apache-2.0"
Expand Down
9 changes: 1 addition & 8 deletions src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ pub fn parse_arguments() -> ArgMatches<'static> {
.about("Allows to manage drogue apps and devices in a drogue-cloud instance")
.arg(config_file_arg)
.arg(verbose)
.arg(&context_arg)
.setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand(
SubCommand::with_name(Verbs::create.as_ref())
.visible_alias("add")
.about("create a resource in the drogue-cloud registry")
.setting(AppSettings::ArgRequiredElseHelp)
.arg(&context_arg)
.subcommand(
SubCommand::with_name(Resources::device.as_ref())
.about("create a device.")
Expand All @@ -178,7 +178,6 @@ pub fn parse_arguments() -> ArgMatches<'static> {
.visible_alias("remove")
.about("delete a resource in the drogue-cloud registry")
.setting(AppSettings::ArgRequiredElseHelp)
.arg(&context_arg)
.subcommand(
SubCommand::with_name(Resources::device.as_ref())
.about("delete a device.")
Expand All @@ -195,7 +194,6 @@ pub fn parse_arguments() -> ArgMatches<'static> {
SubCommand::with_name(Verbs::get.as_ref())
.about("Display one or many resources from the drogue-cloud registry")
.setting(AppSettings::ArgRequiredElseHelp)
.arg(&context_arg)
.subcommand(
SubCommand::with_name(Resources::device.as_ref())
.about("Retrieve a device spec.")
Expand Down Expand Up @@ -228,7 +226,6 @@ pub fn parse_arguments() -> ArgMatches<'static> {
.visible_alias("update")
.about("Update a resource from the drogue-cloud registry")
.setting(AppSettings::ArgRequiredElseHelp)
.arg(&context_arg)
.subcommand(
SubCommand::with_name(Resources::device.as_ref())
.about("Edit a device spec.")
Expand All @@ -245,27 +242,23 @@ pub fn parse_arguments() -> ArgMatches<'static> {
)
.subcommand(
SubCommand::with_name(Other_commands::version.as_ref())
.arg(&context_arg)
.about("Print version information."),
)
.subcommand(
SubCommand::with_name(Other_commands::login.as_ref())
.arg(&token_arg)
.about("Log into a drogue cloud installation.")
.arg(&url_arg)
.arg(&context_arg)
.arg(&login_keep_current),
)
// todo : deprecated
.subcommand(
SubCommand::with_name(Other_commands::token.as_ref())
.arg(&context_arg)
.about("--token is deprecated, use 'drg whoami --token' instead"),
)
.subcommand(
SubCommand::with_name(Other_commands::whoami.as_ref())
.about("Print cluster adress, version and default app(if any)")
.arg(&context_arg)
.arg(
token_arg
.clone()
Expand Down
8 changes: 2 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ fn main() -> Result<()> {
let matches = arguments::parse_arguments();
let config_path = matches.value_of(Parameters::config);
let (command, submatches) = matches.subcommand();
let context_arg = if let Some(submatches) = submatches {
submatches
let context_arg = matches
.value_of(Parameters::context)
.map(|s| s.to_string())
} else {
None
};
.map(|s| s.to_string());

simple_logger::SimpleLogger::new()
.with_level(util::log_level(&matches))
Expand Down

0 comments on commit a97cc8e

Please sign in to comment.