1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

cut: fix formatting, use constant values

This commit is contained in:
Yagiz Degirmenci 2021-04-03 20:21:57 +03:00
parent cfc3d52be4
commit 7e677b3e6c
2 changed files with 26 additions and 10 deletions

View file

@ -494,7 +494,6 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long(options::COMPLEMENT)
.help("invert the filter - instead of displaying only the filtered columns, display all but those columns")
.takes_value(false)
)
.arg(
Arg::with_name(options::ONLY_DELIMITED)
@ -524,7 +523,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
)
.get_matches_from(args);
let complement = matches.is_present("complement");
let complement = matches.is_present(options::COMPLEMENT);
let mode_parse = match (
matches.value_of(options::BYTES),
@ -536,7 +535,12 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
Mode::Bytes(
ranges,
Options {
out_delim: Some(matches.value_of(options::OUTPUT_DELIMITER).unwrap_or_default().to_owned()),
out_delim: Some(
matches
.value_of(options::OUTPUT_DELIMITER)
.unwrap_or_default()
.to_owned(),
),
zero_terminated: matches.is_present(options::ZERO_TERMINATED),
},
)
@ -547,7 +551,12 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
Mode::Characters(
ranges,
Options {
out_delim: Some(matches.value_of(options::OUTPUT_DELIMITER).unwrap_or_default().to_owned()),
out_delim: Some(
matches
.value_of(options::OUTPUT_DELIMITER)
.unwrap_or_default()
.to_owned(),
),
zero_terminated: matches.is_present(options::ZERO_TERMINATED),
},
)
@ -621,10 +630,18 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
let mode_parse = match mode_parse {
Err(_) => mode_parse,
Ok(mode) => match mode {
Mode::Bytes(_, _) | Mode::Characters(_, _) if matches.is_present("delimiter") => Err(
msg_opt_only_usable_if!("printing a sequence of fields", "--delimiter", "-d"),
),
Mode::Bytes(_, _) | Mode::Characters(_, _) if matches.is_present("only-delimited") => {
Mode::Bytes(_, _) | Mode::Characters(_, _)
if matches.is_present(options::DELIMITER) =>
{
Err(msg_opt_only_usable_if!(
"printing a sequence of fields",
"--delimiter",
"-d"
))
}
Mode::Bytes(_, _) | Mode::Characters(_, _)
if matches.is_present(options::ONLY_DELIMITED) =>
{
Err(msg_opt_only_usable_if!(
"printing a sequence of fields",
"--only-delimited",

View file

@ -80,8 +80,7 @@ fn print_version() {
fn print_usage(opts: &Options) {
let brief = "Run COMMAND, with modified buffering operations for its standard streams\n \
Mandatory arguments to long options are mandatory for short options too.";
let explanation =
"If MODE is 'L' the corresponding stream will be line buffered.\n \
let explanation = "If MODE is 'L' the corresponding stream will be line buffered.\n \
This option is invalid with standard input.\n\n \
If MODE is '0' the corresponding stream will be unbuffered.\n\n \
Otherwise MODE is a number which may be followed by one of the following:\n\n \