From b774886f65e96e23196466de89ed946a83ff3d8b Mon Sep 17 00:00:00 2001 From: veju Date: Sat, 13 Dec 2025 18:58:10 +0530 Subject: [PATCH 1/2] add version support --- src/sed/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sed/mod.rs b/src/sed/mod.rs index dc1333d4..9ec10fa1 100644 --- a/src/sed/mod.rs +++ b/src/sed/mod.rs @@ -24,7 +24,7 @@ use crate::sed::command::{ProcessingContext, StringSpace}; use crate::sed::compiler::compile; use crate::sed::processor::process_all_files; use crate::sed::script_line_provider::ScriptValue; -use clap::{Arg, ArgMatches, Command, arg}; +use clap::{Arg, ArgMatches, Command, arg, crate_version}; use std::collections::HashMap; use std::path::PathBuf; use uucore::error::{UResult, UUsageError}; @@ -47,6 +47,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { #[allow(clippy::cognitive_complexity)] pub fn uu_app() -> Command { Command::new(uucore::util_name()) + .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) .infer_long_args(true) From e64fc4bf0b317b141c929a1f048c136999a8bb38 Mon Sep 17 00:00:00 2001 From: veju Date: Sat, 13 Dec 2025 19:29:06 +0530 Subject: [PATCH 2/2] adds testing --- tests/by-util/test_sed.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/by-util/test_sed.rs b/tests/by-util/test_sed.rs index b8ec7d03..b12095d1 100644 --- a/tests/by-util/test_sed.rs +++ b/tests/by-util/test_sed.rs @@ -24,6 +24,22 @@ fn test_invalid_arg() { new_ucmd!().arg("--definitely-invalid").fails().code_is(1); } +#[test] +fn test_version() { + let short = new_ucmd!() + .arg("-V") + .succeeds() + .no_stderr() + .stdout_str() + .to_owned(); + + new_ucmd!() + .arg("--version") + .succeeds() + .no_stderr() + .stdout_is(short); +} + #[test] fn test_debug() { new_ucmd!().args(&["--debug", ""]).succeeds();