From a6816c1613779c563a666c206120969e928a8093 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Thu, 29 Sep 2022 15:35:47 +0200 Subject: [PATCH] chroot: update to clap 4 --- src/uu/chroot/Cargo.toml | 2 +- src/uu/chroot/src/chroot.rs | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/uu/chroot/Cargo.toml b/src/uu/chroot/Cargo.toml index 9475b775e..a021d207a 100644 --- a/src/uu/chroot/Cargo.toml +++ b/src/uu/chroot/Cargo.toml @@ -15,7 +15,7 @@ edition = "2021" path = "src/chroot.rs" [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", features=["entries", "fs"] } [[bin]] diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index 1414da666..c80b4ab87 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -10,7 +10,7 @@ mod error; use crate::error::ChrootError; -use clap::{crate_version, Arg, Command}; +use clap::{crate_version, Arg, ArgAction, Command}; use std::ffi::CString; use std::io::Error; use std::os::unix::prelude::OsStrExt; @@ -49,7 +49,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { None => return Err(ChrootError::MissingNewRoot.into()), }; - let skip_chdir = matches.contains_id(options::SKIP_CHDIR); + let skip_chdir = matches.get_flag(options::SKIP_CHDIR); // We are resolving the path in case it is a symlink or /. or /../ if skip_chdir && canonicalize(newroot, MissingHandling::Normal, ResolveMode::Logical) @@ -116,7 +116,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> Command<'a> { +pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) @@ -168,13 +168,14 @@ pub fn uu_app<'a>() -> Command<'a> { "Use this option to not change the working directory \ to / after changing the root directory to newroot, \ i.e., inside the chroot.", - ), + ) + .action(ArgAction::SetTrue), ) .arg( Arg::new(options::COMMAND) + .action(ArgAction::Append) .value_hint(clap::ValueHint::CommandName) .hide(true) - .multiple_occurrences(true) .index(2), ) }