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) 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();