greengate_runtime/names.rs
1//! Every name the tool says about itself, in one place (ADR-0064
2//! `harness.renames`, plan "amont ships as greengate").
3//!
4//! Messages, usage text, error prefixes, `--version` lines and command hints
5//! are built from these, never from a literal: a later name is one change
6//! here. The names test (`crates/greengate/tests/it/names.rs`) fails on a new
7//! literal `"amont "`, `"amont: "` or `"amont-fleet"` in any other source.
8//!
9//! Not here: the names the tool READS (env vars, git config keys,
10//! `amont.conf`, ledgers, state paths, markers, the slots contract). Those
11//! keep their old spelling until plan 3a-2 reads both.
12//!
13//! In a format string, name the constant inline: `eprintln!("{BIN}: …")`.
14//! For a `&'static str` built at compile time, use the [`bin!`] macro with
15//! `concat!`.
16
17/// The hook binary's name as a literal, for `concat!` in a `&'static str`.
18#[doc(hidden)]
19#[macro_export]
20macro_rules! bin {
21 () => {
22 "greengate"
23 };
24}
25
26/// The fleet binary's name as a literal, for `concat!` in a `&'static str`.
27#[doc(hidden)]
28#[macro_export]
29macro_rules! fleet_bin {
30 () => {
31 "greengate-fleet"
32 };
33}
34
35/// The product's name, as it introduces itself.
36pub const PRODUCT: &str = "greengate";
37
38/// The hook binary.
39pub const BIN: &str = bin!();
40
41/// The fleet binary.
42pub const FLEET_BIN: &str = fleet_bin!();
43
44/// The hook binary's old name, still installed as an alias (a copy).
45pub const OLD_BIN: &str = "amont";
46
47/// The fleet binary's old name, still installed as an alias (a copy).
48pub const OLD_FLEET_BIN: &str = "amont-fleet";
49
50/// The repository the releases come from.
51pub const REPO: &str = "greenharness/greengate";
52
53/// The one-line installer for Linux and macOS.
54pub const INSTALLER_URL: &str =
55 "https://raw.githubusercontent.com/greenharness/greengate/main/install/install.sh";
56
57/// The crate `cargo install` takes.
58pub const CRATE: &str = "greengate";
59
60/// The npm package.
61pub const NPM_PACKAGE: &str = "@greenharness/greengate";
62
63/// The Homebrew formula, tap-qualified.
64pub const BREW_FORMULA: &str = "fredericrous/tap/greengate";
65
66#[cfg(test)]
67mod tests {
68 use super::*;
69
70 #[test]
71 fn the_macros_and_the_constants_agree() {
72 assert_eq!(BIN, PRODUCT);
73 assert_eq!(FLEET_BIN, concat!(bin!(), "-fleet"));
74 assert_eq!(CRATE, BIN);
75 assert!(NPM_PACKAGE.ends_with(BIN));
76 assert!(BREW_FORMULA.ends_with(BIN));
77 assert!(INSTALLER_URL.contains(REPO));
78 }
79}