1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57: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" path = "src/stdbuf.rs"
[dependencies] [dependencies]
clap = { version = "3.2", features = ["wrap_help", "cargo"] } clap = { version = "4.0", features = ["wrap_help", "cargo"] }
tempfile = "3" tempfile = "3"
uucore = { version=">=0.0.16", package="uucore", path="../../uucore" } uucore = { version=">=0.0.16", package="uucore", path="../../uucore" }

View file

@ -10,7 +10,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, Arg, ArgMatches, Command}; use clap::{crate_version, Arg, ArgAction, ArgMatches, Command};
use std::fs::File; use std::fs::File;
use std::io::{self, Write}; use std::io::{self, Write};
use std::os::unix::process::ExitStatusExt; 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 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 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 mut tmp_dir = tempdir().unwrap();
let (preload_env, libstdbuf) = get_preload_env(&mut tmp_dir).map_err_context(String::new)?; 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()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
@ -227,8 +227,7 @@ pub fn uu_app<'a>() -> Command<'a> {
) )
.arg( .arg(
Arg::new(options::COMMAND) Arg::new(options::COMMAND)
.multiple_occurrences(true) .action(ArgAction::Append)
.takes_value(true)
.hide(true) .hide(true)
.required(true) .required(true)
.value_hint(clap::ValueHint::CommandName), .value_hint(clap::ValueHint::CommandName),

View file

@ -27,17 +27,10 @@ fn test_stdbuf_line_buffered_stdout() {
fn test_stdbuf_no_buffer_option_fails() { fn test_stdbuf_no_buffer_option_fails() {
let ts = TestScenario::new(util_name!()); let ts = TestScenario::new(util_name!());
ts.ucmd().args(&["head"]).fails().stderr_is(&format!( ts.ucmd()
"error: The following required arguments were not provided:\n \ .args(&["head"])
--input <MODE>\n \ .fails()
--output <MODE>\n \ .stderr_contains("The following required arguments were not provided:");
--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()
));
} }
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]