1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 05:27:45 +00:00

pwd: update to clap 4

This commit is contained in:
Terts Diepraam 2022-09-30 16:15:29 +02:00
parent 62b963a353
commit 9dc9e44cd5
2 changed files with 8 additions and 5 deletions

View file

@ -15,7 +15,7 @@ edition = "2021"
path = "src/pwd.rs" path = "src/pwd.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]]

View file

@ -5,6 +5,7 @@
// * For the full copyright and license information, please view the LICENSE // * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code. // * file that was distributed with this source code.
use clap::ArgAction;
use clap::{crate_version, Arg, Command}; use clap::{crate_version, Arg, Command};
use std::env; use std::env;
use std::io; use std::io;
@ -125,7 +126,7 @@ fn logical_path() -> io::Result<PathBuf> {
#[uucore::main] #[uucore::main]
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 cwd = if matches.contains_id(OPT_LOGICAL) { let cwd = if matches.get_flag(OPT_LOGICAL) {
logical_path() logical_path()
} else { } else {
physical_path() physical_path()
@ -148,7 +149,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)
@ -158,13 +159,15 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(OPT_LOGICAL) Arg::new(OPT_LOGICAL)
.short('L') .short('L')
.long(OPT_LOGICAL) .long(OPT_LOGICAL)
.help("use PWD from environment, even if it contains symlinks"), .help("use PWD from environment, even if it contains symlinks")
.action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(OPT_PHYSICAL) Arg::new(OPT_PHYSICAL)
.short('P') .short('P')
.long(OPT_PHYSICAL) .long(OPT_PHYSICAL)
.overrides_with(OPT_LOGICAL) .overrides_with(OPT_LOGICAL)
.help("avoid all symlinks"), .help("avoid all symlinks")
.action(ArgAction::SetTrue),
) )
} }