From c6fd9e488b2faf7851761fdfe9e81e0d093c2af8 Mon Sep 17 00:00:00 2001 From: DeFiDude <59237470+DeFiDude@users.noreply.github.com> Date: Fri, 13 Nov 2026 13:03:30 -0700 Subject: [PATCH] lxmd: print the LXMF and Reticulum versions it follows; drop -c and -V --- crates/lxmf-tools/src/commands/lxmd.rs | 12 ++++++++++++ crates/lxmf-tools/src/lxmd_cli.rs | 24 ++++++++++++++++++++++-- crates/lxmf-tools/tests/lxmd_cli.rs | 14 ++++++++++++-- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/crates/lxmf-tools/src/commands/lxmd.rs b/crates/lxmf-tools/src/commands/lxmd.rs index a23ca7a..04d81ae 100644 --- a/crates/lxmf-tools/src/commands/lxmd.rs +++ b/crates/lxmf-tools/src/commands/lxmd.rs @@ -6338,6 +6338,18 @@ fn initialize_storage_namespace(config_dir: &Path) -> std::io::Result<()> { pub(crate) async fn main() { let args = Args::parse(); + if args.version { + println!( + "{}", + rns_tools::version_line( + "lxmd-rs", + env!("CARGO_PKG_VERSION"), + &[("LXMF", lxmf_tools::lxmd_cli::LXMF_COMPAT_VERSION)], + ) + ); + return; + } + if args.exampleconfig { println!("{}", example_config()); return; diff --git a/crates/lxmf-tools/src/lxmd_cli.rs b/crates/lxmf-tools/src/lxmd_cli.rs index c9fe9ea..e57f45e 100644 --- a/crates/lxmf-tools/src/lxmd_cli.rs +++ b/crates/lxmf-tools/src/lxmd_cli.rs @@ -26,17 +26,20 @@ impl SendMethod { } } +/// The LXMF release `lxmd-rs` follows, named in its `--version` line. +pub const LXMF_COMPAT_VERSION: &str = "1.3.0"; + #[derive(Parser)] #[command( name = "lxmd-rs", bin_name = "lxmd-rs", about = "LXMF Propagation Daemon", - version, + disable_version_flag = true, infer_long_args = true )] pub struct Args { /// Path to configuration directory. - #[arg(short, long)] + #[arg(long)] pub config: Option, /// Path to alternative Reticulum configuration directory. @@ -80,6 +83,10 @@ pub struct Args { #[arg(long)] pub exampleconfig: bool, + /// Print version and exit. + #[arg(long)] + pub version: bool, + /// Service mode; the process remains in the foreground. #[arg(short = 's', long)] pub service: bool, @@ -264,6 +271,19 @@ mod tests { assert_eq!(args.identity.as_deref(), Some(Path::new("/tmp/id"))); } + // lxmd.py has `--config` and `--version` only: no `-c`, no `-V`. + #[test] + fn short_forms_upstream_lacks_are_refused() { + for flag in [&["-c", "/tmp/lxmd"][..], &["-V"]] { + let error = Args::try_parse_from(["lxmd"].iter().chain(flag)) + .err() + .unwrap_or_else(|| panic!("{flag:?} must be refused")); + assert_eq!(error.kind(), clap::error::ErrorKind::UnknownArgument); + assert_eq!(error.exit_code(), 2, "argparse exits 2"); + } + assert!(Args::try_parse_from(["lxmd", "--version"]).unwrap().version); + } + #[test] fn parse_destination_hash_accepts_pretty_hex() { let hash = diff --git a/crates/lxmf-tools/tests/lxmd_cli.rs b/crates/lxmf-tools/tests/lxmd_cli.rs index 2721026..381c50f 100644 --- a/crates/lxmf-tools/tests/lxmd_cli.rs +++ b/crates/lxmf-tools/tests/lxmd_cli.rs @@ -188,7 +188,12 @@ fn version_reports_binary_name_and_package_version() { ); assert_eq!( stdout(&output).trim(), - format!("lxmd-rs {}", env!("CARGO_PKG_VERSION")) + format!( + "lxmd-rs {} (LXMF {}, Reticulum {})", + env!("CARGO_PKG_VERSION"), + lxmf_tools::lxmd_cli::LXMF_COMPAT_VERSION, + rns_tools::RETICULUM_COMPAT_VERSION + ) ); assert!(stderr(&output).is_empty()); } @@ -204,7 +209,12 @@ fn rust_binary_runs_cli() { ); assert_eq!( stdout(&output).trim(), - format!("lxmd-rs {}", env!("CARGO_PKG_VERSION")) + format!( + "lxmd-rs {} (LXMF {}, Reticulum {})", + env!("CARGO_PKG_VERSION"), + lxmf_tools::lxmd_cli::LXMF_COMPAT_VERSION, + rns_tools::RETICULUM_COMPAT_VERSION + ) ); assert!(stderr(&output).is_empty()); }