Skip to content

Commit

Permalink
yes: allow --version
Browse files Browse the repository at this point in the history
Test: tests/help/help-version-getopt.sh
  • Loading branch information
sylvestre committed Jun 19, 2023
1 parent 66723e0 commit bf7f378
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/uu/yes/src/yes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// cSpell:ignore strs

use clap::{builder::ValueParser, Arg, ArgAction, Command};
use clap::{builder::ValueParser, crate_version, Arg, ArgAction, Command};
use std::error::Error;
use std::ffi::OsString;
use std::io::{self, Write};
Expand Down Expand Up @@ -44,6 +44,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {

pub fn uu_app() -> Command {
Command::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.override_usage(format_usage(USAGE))
.arg(
Expand Down
5 changes: 5 additions & 0 deletions tests/by-util/test_yes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}

#[test]
fn test_version() {
new_ucmd!().arg("--version").succeeds();
}

#[test]
fn test_simple() {
run(NO_ARGS, b"y\ny\ny\ny\n");
Expand Down

0 comments on commit bf7f378

Please sign in to comment.