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
10 changes: 5 additions & 5 deletions src/uu/echo/src/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::ffi::{OsStr, OsString};
use std::io::{StdoutLock, Write, stdout};
use uucore::error::UResult;
use uucore::format::{FormatChar, OctalParsing, parse_escape_only};
use uucore::{format_usage, os_str_as_bytes};
use uucore::{crate_version, format_usage, os_str_as_bytes};

use uucore::translate;

Expand Down Expand Up @@ -166,7 +166,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
uu_app().print_help()?;
return Ok(());
} else if first_arg == "--version" && args.peek().is_none() {
write!(stdout(), "{}", uu_app().render_version())?;
writeln!(stdout(), "echo {}", crate_version!())?;
return Ok(());
}

Expand All @@ -186,17 +186,17 @@ pub fn uu_app() -> Command {
// Note: echo is different from the other utils in that it should **not**
// have `infer_long_args(true)`, because, for example, `--ver` should be
// printed as `--ver` and not show the version text.
Command::new(uucore::util_name())
Command::new("echo")
// TrailingVarArg specifies the final positional argument is a VarArg
// and it doesn't attempts the parse any further args.
// Final argument must have multiple(true) or the usage string equivalent.
.trailing_var_arg(true)
.allow_hyphen_values(true)
.version(uucore::crate_version!())
.version(crate_version!())
.about(translate!("echo-about"))
.after_help(translate!("echo-after-help"))
.override_usage(format_usage(&translate!("echo-usage")))
.help_template(uucore::localized_help_template(uucore::util_name()))
.help_template(uucore::localized_help_template("echo"))
.arg(
Arg::new(options::NO_NEWLINE)
.short('n')
Expand Down
13 changes: 7 additions & 6 deletions src/uu/false/src/false.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// file that was distributed with this source code.
use clap::{Arg, ArgAction, Command};
use std::io::Write;
use uucore::translate;
use uucore::{crate_version, translate};

// uucore::main does not support no-result
pub fn uumain(mut args: impl uucore::Args) -> i32 {
Expand All @@ -16,23 +16,24 @@ pub fn uumain(mut args: impl uucore::Args) -> i32 {
let error = if flag == "--help" {
uu_app().print_help()
} else if flag == "--version" {
write!(std::io::stdout(), "{}", uu_app().render_version())
// avoid uu_app for smaller binary size
writeln!(std::io::stdout(), "false {}", crate_version!())
} else {
return 1;
};

if let Err(print_fail) = error
&& print_fail.kind() != std::io::ErrorKind::BrokenPipe
{
let _ = writeln!(std::io::stderr(), "{}: {print_fail}", uucore::util_name());
let _ = writeln!(std::io::stderr(), "false: {print_fail}");
}
1
}

pub fn uu_app() -> Command {
Command::new(uucore::util_name())
.version(uucore::crate_version!())
.help_template(uucore::localized_help_template(uucore::util_name()))
Command::new("false")
.version(crate_version!())
.help_template(uucore::localized_help_template("false"))
.about(translate!("false-about"))
// We provide our own help and version options, to ensure maximum compatibility with GNU.
.disable_help_flag(true)
Expand Down
13 changes: 7 additions & 6 deletions src/uu/true/src/true.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// file that was distributed with this source code.
use clap::{Arg, ArgAction, Command};
use std::io::Write;
use uucore::translate;
use uucore::{crate_version, translate};

// uucore::main does not support no-result
pub fn uumain(mut args: impl uucore::Args) -> i32 {
Expand All @@ -16,7 +16,8 @@ pub fn uumain(mut args: impl uucore::Args) -> i32 {
let error = if flag == "--help" {
uu_app().print_help()
} else if flag == "--version" {
write!(std::io::stdout(), "{}", uu_app().render_version())
// avoid uu_app for smaller binary size
writeln!(std::io::stdout(), "true {}", crate_version!())
} else {
return 0;
};
Expand All @@ -25,7 +26,7 @@ pub fn uumain(mut args: impl uucore::Args) -> i32 {
&& print_fail.kind() != std::io::ErrorKind::BrokenPipe
{
// Try to display this error.
let _ = writeln!(std::io::stderr(), "{}: {print_fail}", uucore::util_name());
let _ = writeln!(std::io::stderr(), "true: {print_fail}");
// Mirror GNU options. When failing to print warnings or version flags, then we exit
// with FAIL. This avoids allocation some error information which may result in yet
// other types of failure.
Expand All @@ -35,9 +36,9 @@ pub fn uumain(mut args: impl uucore::Args) -> i32 {
}

pub fn uu_app() -> Command {
Command::new(uucore::util_name())
.version(uucore::crate_version!())
.help_template(uucore::localized_help_template(uucore::util_name()))
Command::new("true")
.version(crate_version!())
.help_template(uucore::localized_help_template("true"))
.about(translate!("true-about"))
// We provide our own help and version options, to ensure maximum compatibility with GNU.
.disable_help_flag(true)
Expand Down
Loading