mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +00:00
dircolors: update to clap 4
This commit is contained in:
parent
811a06fd66
commit
aaf1e362bf
2 changed files with 15 additions and 17 deletions
|
@ -15,7 +15,7 @@ edition = "2021"
|
|||
path = "src/dircolors.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "3.2", features = ["wrap_help", "cargo"] }
|
||||
clap = { version = "4.0", features = ["wrap_help", "cargo"] }
|
||||
glob = "0.3.0"
|
||||
uucore = { version=">=0.0.16", package="uucore", path="../../uucore" }
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::env;
|
|||
use std::fs::File;
|
||||
use std::io::{BufRead, BufReader};
|
||||
|
||||
use clap::{crate_version, Arg, Command};
|
||||
use clap::{crate_version, Arg, ArgAction, Command};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{UResult, USimpleError, UUsageError};
|
||||
|
||||
|
@ -75,9 +75,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
|
||||
// clap provides .conflicts_with / .conflicts_with_all, but we want to
|
||||
// manually handle conflicts so we can match the output of GNU coreutils
|
||||
if (matches.contains_id(options::C_SHELL) || matches.contains_id(options::BOURNE_SHELL))
|
||||
&& (matches.contains_id(options::PRINT_DATABASE)
|
||||
|| matches.contains_id(options::PRINT_LS_COLORS))
|
||||
if (matches.get_flag(options::C_SHELL) || matches.get_flag(options::BOURNE_SHELL))
|
||||
&& (matches.get_flag(options::PRINT_DATABASE) || matches.get_flag(options::PRINT_LS_COLORS))
|
||||
{
|
||||
return Err(UUsageError::new(
|
||||
1,
|
||||
|
@ -86,15 +85,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
));
|
||||
}
|
||||
|
||||
if matches.contains_id(options::PRINT_DATABASE) && matches.contains_id(options::PRINT_LS_COLORS)
|
||||
{
|
||||
if matches.get_flag(options::PRINT_DATABASE) && matches.get_flag(options::PRINT_LS_COLORS) {
|
||||
return Err(UUsageError::new(
|
||||
1,
|
||||
"options --print-database and --print-ls-colors are mutually exclusive",
|
||||
));
|
||||
}
|
||||
|
||||
if matches.contains_id(options::PRINT_DATABASE) {
|
||||
if matches.get_flag(options::PRINT_DATABASE) {
|
||||
if !files.is_empty() {
|
||||
return Err(UUsageError::new(
|
||||
1,
|
||||
|
@ -109,11 +107,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
let mut out_format = if matches.contains_id(options::C_SHELL) {
|
||||
let mut out_format = if matches.get_flag(options::C_SHELL) {
|
||||
OutputFmt::CShell
|
||||
} else if matches.contains_id(options::BOURNE_SHELL) {
|
||||
} else if matches.get_flag(options::BOURNE_SHELL) {
|
||||
OutputFmt::Shell
|
||||
} else if matches.contains_id(options::PRINT_LS_COLORS) {
|
||||
} else if matches.get_flag(options::PRINT_LS_COLORS) {
|
||||
OutputFmt::Display
|
||||
} else {
|
||||
OutputFmt::Unknown
|
||||
|
@ -168,7 +166,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)
|
||||
|
@ -182,7 +180,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
.visible_alias("bourne-shell")
|
||||
.overrides_with(options::C_SHELL)
|
||||
.help("output Bourne shell code to set LS_COLORS")
|
||||
.display_order(1),
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::C_SHELL)
|
||||
|
@ -191,26 +189,26 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
.visible_alias("c-shell")
|
||||
.overrides_with(options::BOURNE_SHELL)
|
||||
.help("output C shell code to set LS_COLORS")
|
||||
.display_order(2),
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::PRINT_DATABASE)
|
||||
.long("print-database")
|
||||
.short('p')
|
||||
.help("print the byte counts")
|
||||
.display_order(3),
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::PRINT_LS_COLORS)
|
||||
.long("print-ls-colors")
|
||||
.help("output fully escaped colors for display")
|
||||
.display_order(4),
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::FILE)
|
||||
.hide(true)
|
||||
.value_hint(clap::ValueHint::FilePath)
|
||||
.multiple_occurrences(true),
|
||||
.action(ArgAction::Append),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue