From 80a71d9023f1124a2e88be458f88d4635bd2ac3f Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Wed, 17 Nov 2021 22:21:00 -0800 Subject: [PATCH] cli.rs: Point user at manual --- Cargo.lock | 1 + Cargo.toml | 1 + src/cli.rs | 19 ++++++++++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ab0cdc..563ef50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -132,6 +132,7 @@ dependencies = [ "glob", "hostname", "indicatif", + "lazy_static", "libc", "log", "quit", diff --git a/Cargo.toml b/Cargo.toml index eb696c0..32636be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ futures = "0.3.8" glob = "0.3.0" hostname = "0.3.1" indicatif = "0.17.0-beta.1" +lazy_static = "1.4.0" libc = "0.2.81" log = "0.4.11" quit = "1.1.2" diff --git a/src/cli.rs b/src/cli.rs index 720b99a..6644f19 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,8 +1,19 @@ //! Global CLI Setup. use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; +use lazy_static::lazy_static; + use crate::command; +lazy_static! { + static ref CONFIG_HELP: String = { + format!(r#"If this argument is not specified, Colmena will search upwards from the current working directory for a file named "flake.nix" or "hive.nix". This behavior is disabled if --config/-f is given explicitly. + +For a sample configuration, see . +"#, env!("CARGO_PKG_VERSION")) + }; +} + macro_rules! register_command { ($module:ident, $app:ident) => { $app = $app.subcommand(command::$module::subcommand()); @@ -25,9 +36,10 @@ macro_rules! handle_command { } pub fn build_cli(include_internal: bool) -> App<'static, 'static> { + let version = env!("CARGO_PKG_VERSION"); let mut app = App::new("Colmena") .bin_name("colmena") - .version("0.1.0") + .version(version) .author("Zhaofeng Li ") .about("NixOS deployment tool") .global_setting(AppSettings::ColoredHelp) @@ -45,10 +57,7 @@ pub fn build_cli(include_internal: bool) -> App<'static, 'static> { // or "hive.nix". This behavior is disabled if --config/-f // is explicitly supplied by the user (occurrences_of > 0). .default_value("hive.nix") - .long_help(r#"If this argument is not specified, Colmena will search upwards from the current working directory for a file named "flake.nix" or "hive.nix". This behavior is disabled if --config/-f is given explicitly. - -For a sample configuration, see . -"#) + .long_help(&CONFIG_HELP) .global(true)) .arg(Arg::with_name("show-trace") .long("show-trace")