1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

stdbuf: update to clap 4

This commit is contained in:
Terts Diepraam 2022-10-01 00:11:02 +02:00
parent 1f67351efa
commit b6a4f32889
3 changed files with 10 additions and 18 deletions

View file

@ -15,7 +15,7 @@ edition = "2021"
path = "src/stdbuf.rs"
[dependencies]
clap = { version = "3.2", features = ["wrap_help", "cargo"] }
clap = { version = "4.0", features = ["wrap_help", "cargo"] }
tempfile = "3"
uucore = { version=">=0.0.16", package="uucore", path="../../uucore" }

View file

@ -10,7 +10,7 @@
#[macro_use]
extern crate uucore;
use clap::{crate_version, Arg, ArgMatches, Command};
use clap::{crate_version, Arg, ArgAction, ArgMatches, Command};
use std::fs::File;
use std::io::{self, Write};
use std::os::unix::process::ExitStatusExt;
@ -162,9 +162,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let options = ProgramOptions::try_from(&matches).map_err(|e| UUsageError::new(125, e.0))?;
let mut command_values = matches.values_of::<&str>(options::COMMAND).unwrap();
let mut command_values = matches.get_many::<String>(options::COMMAND).unwrap();
let mut command = process::Command::new(command_values.next().unwrap());
let command_params: Vec<&str> = command_values.collect();
let command_params: Vec<&str> = command_values.map(|s| s.as_ref()).collect();
let mut tmp_dir = tempdir().unwrap();
let (preload_env, libstdbuf) = get_preload_env(&mut tmp_dir).map_err_context(String::new)?;
@ -193,7 +193,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
}
pub fn uu_app<'a>() -> Command<'a> {
pub fn uu_app() -> Command {
Command::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
@ -227,8 +227,7 @@ pub fn uu_app<'a>() -> Command<'a> {
)
.arg(
Arg::new(options::COMMAND)
.multiple_occurrences(true)
.takes_value(true)
.action(ArgAction::Append)
.hide(true)
.required(true)
.value_hint(clap::ValueHint::CommandName),

View file

@ -27,17 +27,10 @@ fn test_stdbuf_line_buffered_stdout() {
fn test_stdbuf_no_buffer_option_fails() {
let ts = TestScenario::new(util_name!());
ts.ucmd().args(&["head"]).fails().stderr_is(&format!(
"error: The following required arguments were not provided:\n \
--input <MODE>\n \
--output <MODE>\n \
--error <MODE>\n\n\
USAGE:\n \
{1} {0} OPTION... COMMAND\n\n\
For more information try --help",
ts.util_name,
ts.bin_path.to_string_lossy()
));
ts.ucmd()
.args(&["head"])
.fails()
.stderr_contains("The following required arguments were not provided:");
}
#[cfg(not(target_os = "windows"))]