Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/sed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions tests/by-util/test_sed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-V isn't supported upstream

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sylvestre wouldn't it make sense to keep it as an extension? Similar to the coreutils?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok :)

.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();
Expand Down
Loading