Skip to content

Commit

Permalink
Remove lazy-static
Browse files Browse the repository at this point in the history
  • Loading branch information
i1i1 authored and zhaofengli committed Oct 18, 2023
1 parent 8d92dad commit 197010c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 31 deletions.
5 changes: 2 additions & 3 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ futures = "0.3.28"
glob = "0.3.1"
hostname = "0.3.1"
indicatif = "0.17.3"
itertools = "0.10.5"
lazy_static = "1.4.0"
itertools = "0.11.0"
libc = "0.2.144"
log = "0.4.17"
quit = "2.0.0"
regex = "1"
serde = { version = "1.0.163", features = ["derive"] }
serde_json = "1.0"
shell-escape = "0.1.5"
sys-info = "0.9.1"
snafu = { version = "0.7.4", features = ["backtrace", "backtraces-impl-backtrace-crate"] }
sys-info = "0.9.1"
tempfile = "3.5.0"
tokio-stream = "0.1.14"
uuid = { version = "1.3.2", features = ["serde", "v4"] }
Expand Down
43 changes: 18 additions & 25 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ use clap::{
Command as ClapCommand, ValueEnum,
};
use clap_complete::Shell;
use const_format::concatcp;
use const_format::{concatcp, formatcp};
use env_logger::fmt::WriteStyle;
use lazy_static::lazy_static;

use crate::command;

Expand All @@ -34,36 +33,30 @@ const MANUAL_URL: &str = concatcp!(
/// API stability cannot be guaranteed for pre-release versions.
/// Links to the version currently in development automatically
/// leads the user to the unstable manual.
const MANUAL_DISCREPANCY_NOTE: &str = "Note: You are using a pre-release version of Colmena, so the supported options may be different from what's in the manual.";
const MANUAL_DISCREPANCY_NOTE: &str = "\nNote: You are using a pre-release version of Colmena, so the supported options may be different from what's in the manual.";

lazy_static! {
static ref LONG_ABOUT: String = {
let mut message = format!(
r#"NixOS deployment tool
static LONG_ABOUT: &str = formatcp!(
r#"NixOS deployment tool
Colmena helps you deploy to multiple hosts running NixOS.
For more details, read the manual at <{}>.
"#,
MANUAL_URL
);

if !env!("CARGO_PKG_VERSION_PRE").is_empty() {
message += MANUAL_DISCREPANCY_NOTE;
}
{}"#,
MANUAL_URL,
if !env!("CARGO_PKG_VERSION_PRE").is_empty() {
MANUAL_DISCREPANCY_NOTE
} else {
""
}
);

message
};
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.
static CONFIG_HELP: &str = formatcp!(
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, check the manual at <{}>.
"#,
MANUAL_URL
)
};
}
MANUAL_URL
);

/// Display order in `--help` for arguments that should be shown first.
///
Expand Down Expand Up @@ -130,14 +123,14 @@ pub fn build_cli(include_internal: bool) -> ClapCommand {
.version(version)
.author("Zhaofeng Li <hello@zhaofeng.li>")
.about("NixOS deployment tool")
.long_about(LONG_ABOUT.as_str())
.long_about(LONG_ABOUT)
.arg_required_else_help(true)
.arg(Arg::new("config")
.short('f')
.long("config")
.value_name("CONFIG")
.help("Path to a Hive expression, a flake.nix, or a Nix Flake URI")
.long_help(Some(CONFIG_HELP.as_str()))
.long_help(Some(CONFIG_HELP))
.display_order(HELP_ORDER_FIRST)

// The default value is a lie (sort of)!
Expand Down

0 comments on commit 197010c

Please sign in to comment.