diff --git a/README.md b/README.md index 28b3e08..ba667d7 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ Here is a short example: The full set of options can be found at `src/nix/eval.nix`. Run `colmena build` in the same directory to build the configuration, or do `colmena apply` to build and deploy it to all nodes. -## `colmena introspect` +## `colmena eval` Sometimes you may want to extract values from your Hive configuration for consumption in another program (e.g., [OctoDNS](https://github.com/octodns/octodns)). To do that, create a `.nix` file with a lambda: @@ -184,7 +184,7 @@ lib.attrsets.mapAttrs (k: v: v.config.deployment.targetHost) nodes Then you can evaluate with: ``` -colmena introspect your-lambda.nix +colmena eval your-lambda.nix ``` ## `colmena apply-local` diff --git a/src/cli.rs b/src/cli.rs index 6f48166..c8e1043 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -65,12 +65,15 @@ For a sample configuration, see . .index(1) .required(true) .takes_value(true))); + + // deprecated alias + app = app.subcommand(command::eval::deprecated_alias()); } register_command!(apply, app); register_command!(apply_local, app); register_command!(build, app); - register_command!(introspect, app); + register_command!(eval, app); register_command!(upload_keys, app); register_command!(exec, app); register_command!(nix_info, app); @@ -85,11 +88,14 @@ pub async fn run() { handle_command!(apply, matches); handle_command!("apply-local", apply_local, matches); handle_command!(build, matches); - handle_command!(introspect, matches); + handle_command!(eval, matches); handle_command!("upload-keys", upload_keys, matches); handle_command!(exec, matches); handle_command!("nix-info", nix_info, matches); + // deprecated alias + handle_command!("introspect", eval, matches); + if let Some(args) = matches.subcommand_matches("gen-completions") { return gen_completions(args); } diff --git a/src/command/introspect.rs b/src/command/eval.rs similarity index 80% rename from src/command/introspect.rs rename to src/command/eval.rs index 3c6e3f1..4e2c4f3 100644 --- a/src/command/introspect.rs +++ b/src/command/eval.rs @@ -1,11 +1,11 @@ use std::path::PathBuf; -use clap::{Arg, App, SubCommand, ArgMatches}; +use clap::{Arg, App, AppSettings, SubCommand, ArgMatches}; use crate::util; pub fn subcommand() -> App<'static, 'static> { - SubCommand::with_name("introspect") + SubCommand::with_name("eval") .about("Evaluate expressions using the complete configuration") .long_about(r#"Evaluate expressions using the complete configuration @@ -31,7 +31,17 @@ For example, to retrieve the configuration of one node, you may write something .takes_value(false)) } -pub async fn run(_global_args: &ArgMatches<'_>, local_args: &ArgMatches<'_>) { +pub fn deprecated_alias() -> App<'static, 'static> { + subcommand() + .name("introspect") + .setting(AppSettings::Hidden) +} + +pub async fn run(global_args: &ArgMatches<'_>, local_args: &ArgMatches<'_>) { + if let Some("introspect") = global_args.subcommand_name() { + log::warn!("`colmena introspect` has been renamed to `colmena eval`. Please update your scripts."); + } + let hive = util::hive_from_args(local_args).await.unwrap(); if !(local_args.is_present("expression") ^ local_args.is_present("expression_file")) { diff --git a/src/command/mod.rs b/src/command/mod.rs index 7868eb7..33c8ff7 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -1,6 +1,6 @@ pub mod build; pub mod apply; -pub mod introspect; +pub mod eval; pub mod apply_local; pub mod upload_keys; pub mod exec;