mirror of
https://github.com/ratspeak/rsLXMF
synced 2026-11-22 23:10:35 +00:00
lxmd: print the LXMF and Reticulum versions it follows; drop -c and -V
This commit is contained in:
1 parent
ec3924a812
commit
c6fd9e488b
3 files changed
+46
-4
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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<String>,
|
||||
|
||||
/// 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 =
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user