command/eval: Fix introspect alias

On clap 3.0, resetting the App::name still causes clap to complain
that the subcommand doesn't exist in debug mode.
This commit is contained in:
Zhaofeng Li 2022-01-03 10:37:03 -08:00
parent 79d1010356
commit d2762757f0

View file

@ -6,7 +6,16 @@ use crate::util;
use crate::nix::NixError;
pub fn subcommand() -> App<'static> {
App::new("eval")
subcommand_gen("eval")
}
pub fn deprecated_alias() -> App<'static> {
subcommand_gen("introspect")
.setting(AppSettings::Hidden)
}
fn subcommand_gen(name: &str) -> App<'static> {
App::new(name)
.about("Evaluate an expression using the complete configuration")
.long_about(r#"Evaluate an expression using the complete configuration
@ -32,12 +41,6 @@ For example, to retrieve the configuration of one node, you may write something
.takes_value(false))
}
pub fn deprecated_alias() -> App<'static> {
subcommand()
.name("introspect")
.setting(AppSettings::Hidden)
}
pub async fn run(global_args: &ArgMatches, local_args: &ArgMatches) -> Result<(), NixError> {
if let Some("introspect") = global_args.subcommand_name() {
log::warn!("`colmena introspect` has been renamed to `colmena eval`. Please update your scripts.");