diff --git a/leo/cli.rs b/leo/cli.rs index 5a4a0d8e53..5393d0cc66 100644 --- a/leo/cli.rs +++ b/leo/cli.rs @@ -33,7 +33,13 @@ pub trait CLI { fn new<'a, 'b>() -> App<'a, 'b> { let arguments = &Self::ARGUMENTS .iter() - .map(|a| Arg::with_name(a.0).help(a.1).required(a.2).index(a.3)) + .map(|a| { + let mut args = Arg::with_name(a.0).help(a.1).required(a.3).index(a.4); + if a.2.len() > 0 { + args = args.possible_values(a.2); + } + args + }) .collect::>>(); let flags = &Self::FLAGS .iter() @@ -56,7 +62,13 @@ pub trait CLI { .about(s.1) .args( &s.2.iter() - .map(|a| Arg::with_name(a.0).help(a.1).required(a.2).index(a.3)) + .map(|a| { + let mut args = Arg::with_name(a.0).help(a.1).required(a.3).index(a.4); + if a.2.len() > 0 { + args = args.possible_values(a.2); + } + args + }) .collect::>>(), ) .args( diff --git a/leo/cli_types.rs b/leo/cli_types.rs index 77e6085218..a2527635e7 100644 --- a/leo/cli_types.rs +++ b/leo/cli_types.rs @@ -24,9 +24,11 @@ pub type DescriptionType = &'static str; pub type RequiredType = bool; +pub type PossibleValuesType = &'static [&'static str]; + pub type IndexType = u64; -pub type ArgumentType = (NameType, DescriptionType, RequiredType, IndexType); +pub type ArgumentType = (NameType, DescriptionType, PossibleValuesType, RequiredType, IndexType); // Format // "[flag] -f --flag 'Add flag description here'" diff --git a/leo/commands/add.rs b/leo/commands/add.rs index ca1d45a7fc..76084dfdcb 100644 --- a/leo/commands/add.rs +++ b/leo/commands/add.rs @@ -51,6 +51,7 @@ impl CLI for AddCommand { ( "REMOTE", "Install a package from the Aleo Package Manager with the given remote", + &[], false, 1u64, ), diff --git a/leo/commands/login.rs b/leo/commands/login.rs index 4c6b038598..01da218e0e 100644 --- a/leo/commands/login.rs +++ b/leo/commands/login.rs @@ -46,6 +46,7 @@ impl CLI for LoginCommand { ( "NAME", "Sets the authentication token for login to the package manager", + &[], false, 1u64, ), diff --git a/leo/commands/new.rs b/leo/commands/new.rs index d210ff6ebd..033b23186f 100644 --- a/leo/commands/new.rs +++ b/leo/commands/new.rs @@ -37,6 +37,7 @@ impl CLI for NewCommand { ( "NAME", "Sets the resulting package name, defaults to the directory name", + &[], true, 1u64, ), diff --git a/leo/commands/remove.rs b/leo/commands/remove.rs index 4b26ba3e9e..179d1b57a7 100644 --- a/leo/commands/remove.rs +++ b/leo/commands/remove.rs @@ -30,7 +30,13 @@ impl CLI for RemoveCommand { const ABOUT: AboutType = "Uninstall a package from the current package"; const ARGUMENTS: &'static [ArgumentType] = &[ // (name, description, required, index) - ("NAME", "Removes the package from the current directory", true, 1u64), + ( + "NAME", + "Removes the package from the current directory", + &[], + true, + 1u64, + ), ]; const FLAGS: &'static [FlagType] = &[]; const NAME: NameType = "remove"; diff --git a/leo/commands/update.rs b/leo/commands/update.rs index 12df354418..fb4c712d34 100644 --- a/leo/commands/update.rs +++ b/leo/commands/update.rs @@ -133,12 +133,13 @@ impl CLI for UpdateAutomatic { // (name, description, required, index) ( "automatic", - "Enable or disable automatic updates [possible values: true, false]", + "Enable or disable automatic updates", + &["true", "false"], false, 1u64, ), ]; - const FLAGS: &'static [FlagType] = &[("--quiet")]; + const FLAGS: &'static [FlagType] = &["[quiet] -q --quiet 'Suppress outputs to terminal'"]; const NAME: NameType = "automatic"; const OPTIONS: &'static [OptionType] = &[]; const SUBCOMMANDS: &'static [SubCommandType] = &[]; @@ -152,11 +153,7 @@ impl CLI for UpdateAutomatic { let automatic = match automatic { "true" => Some(true), "false" => Some(false), - _ => { - // TODO (raychu86) fix this log output - tracing::info!("Possible values for this flag are `true` or `false`."); - None - } + _ => unreachable!(), }; Ok((automatic, quiet))