mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-17 04:06:18 +00:00
nproc: update to clap 4
This commit is contained in:
parent
405e5fba67
commit
d17c99a3cf
2 changed files with 7 additions and 6 deletions
|
@ -17,7 +17,7 @@ path = "src/nproc.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2.135"
|
libc = "0.2.135"
|
||||||
num_cpus = "1.10"
|
num_cpus = "1.10"
|
||||||
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", features=["fs"] }
|
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["fs"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
// spell-checker:ignore (ToDO) NPROCESSORS nprocs numstr threadstr sysconf
|
// spell-checker:ignore (ToDO) NPROCESSORS nprocs numstr threadstr sysconf
|
||||||
|
|
||||||
use clap::{crate_version, Arg, Command};
|
use clap::{crate_version, Arg, ArgAction, Command};
|
||||||
use std::env;
|
use std::env;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{UResult, USimpleError};
|
use uucore::error::{UResult, USimpleError};
|
||||||
|
@ -60,7 +60,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
Err(_) => usize::MAX,
|
Err(_) => usize::MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut cores = if matches.contains_id(OPT_ALL) {
|
let mut cores = if matches.get_flag(OPT_ALL) {
|
||||||
num_cpus_all()
|
num_cpus_all()
|
||||||
} else {
|
} else {
|
||||||
// OMP_NUM_THREADS doesn't have an impact on --all
|
// OMP_NUM_THREADS doesn't have an impact on --all
|
||||||
|
@ -96,7 +96,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -105,12 +105,13 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(OPT_ALL)
|
Arg::new(OPT_ALL)
|
||||||
.long(OPT_ALL)
|
.long(OPT_ALL)
|
||||||
.help("print the number of cores available to the system"),
|
.help("print the number of cores available to the system")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(OPT_IGNORE)
|
Arg::new(OPT_IGNORE)
|
||||||
.long(OPT_IGNORE)
|
.long(OPT_IGNORE)
|
||||||
.takes_value(true)
|
.value_name("N")
|
||||||
.help("ignore up to N cores"),
|
.help("ignore up to N cores"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue