mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-17 04:06:18 +00:00
paste: update to clap 4
This commit is contained in:
parent
cdde016501
commit
e346253a30
2 changed files with 10 additions and 8 deletions
|
@ -15,7 +15,7 @@ edition = "2021"
|
||||||
path = "src/paste.rs"
|
path = "src/paste.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "3.2", features = ["wrap_help", "cargo"] }
|
clap = { version = "4.0", features = ["wrap_help", "cargo"] }
|
||||||
uucore = { version=">=0.0.16", package="uucore", path="../../uucore" }
|
uucore = { version=">=0.0.16", package="uucore", path="../../uucore" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
// spell-checker:ignore (ToDO) delim
|
// spell-checker:ignore (ToDO) delim
|
||||||
|
|
||||||
use clap::{crate_version, Arg, Command};
|
use clap::{crate_version, Arg, ArgAction, Command};
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{stdin, stdout, BufRead, BufReader, Read, Write};
|
use std::io::{stdin, stdout, BufRead, BufReader, Read, Write};
|
||||||
|
@ -56,14 +56,14 @@ fn read_until<R: Read>(
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let matches = uu_app().try_get_matches_from(args)?;
|
let matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let serial = matches.contains_id(options::SERIAL);
|
let serial = matches.get_flag(options::SERIAL);
|
||||||
let delimiters = matches.get_one::<String>(options::DELIMITER).unwrap();
|
let delimiters = matches.get_one::<String>(options::DELIMITER).unwrap();
|
||||||
let files = matches
|
let files = matches
|
||||||
.get_many::<String>(options::FILE)
|
.get_many::<String>(options::FILE)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.map(|s| s.to_owned())
|
.map(|s| s.to_owned())
|
||||||
.collect();
|
.collect();
|
||||||
let line_ending = if matches.contains_id(options::ZERO_TERMINATED) {
|
let line_ending = if matches.get_flag(options::ZERO_TERMINATED) {
|
||||||
LineEnding::Nul
|
LineEnding::Nul
|
||||||
} else {
|
} else {
|
||||||
LineEnding::Newline
|
LineEnding::Newline
|
||||||
|
@ -72,7 +72,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
paste(files, serial, delimiters, line_ending)
|
paste(files, serial, delimiters, line_ending)
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -81,7 +81,8 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
Arg::new(options::SERIAL)
|
Arg::new(options::SERIAL)
|
||||||
.long(options::SERIAL)
|
.long(options::SERIAL)
|
||||||
.short('s')
|
.short('s')
|
||||||
.help("paste one file at a time instead of in parallel"),
|
.help("paste one file at a time instead of in parallel")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::DELIMITER)
|
Arg::new(options::DELIMITER)
|
||||||
|
@ -95,7 +96,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::FILE)
|
Arg::new(options::FILE)
|
||||||
.value_name("FILE")
|
.value_name("FILE")
|
||||||
.multiple_occurrences(true)
|
.action(ArgAction::Append)
|
||||||
.default_value("-")
|
.default_value("-")
|
||||||
.value_hint(clap::ValueHint::FilePath),
|
.value_hint(clap::ValueHint::FilePath),
|
||||||
)
|
)
|
||||||
|
@ -103,7 +104,8 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
Arg::new(options::ZERO_TERMINATED)
|
Arg::new(options::ZERO_TERMINATED)
|
||||||
.long(options::ZERO_TERMINATED)
|
.long(options::ZERO_TERMINATED)
|
||||||
.short('z')
|
.short('z')
|
||||||
.help("line delimiter is NUL, not newline"),
|
.help("line delimiter is NUL, not newline")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue