1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 04:27:45 +00:00

chroot: update to clap 4

This commit is contained in:
Terts Diepraam 2022-09-29 15:35:47 +02:00
parent c6aabd9023
commit a6816c1613
2 changed files with 7 additions and 6 deletions

View file

@ -15,7 +15,7 @@ edition = "2021"
path = "src/chroot.rs" path = "src/chroot.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", features=["entries", "fs"] } uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["entries", "fs"] }
[[bin]] [[bin]]

View file

@ -10,7 +10,7 @@
mod error; mod error;
use crate::error::ChrootError; use crate::error::ChrootError;
use clap::{crate_version, Arg, Command}; use clap::{crate_version, Arg, ArgAction, Command};
use std::ffi::CString; use std::ffi::CString;
use std::io::Error; use std::io::Error;
use std::os::unix::prelude::OsStrExt; use std::os::unix::prelude::OsStrExt;
@ -49,7 +49,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
None => return Err(ChrootError::MissingNewRoot.into()), 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 /../ // We are resolving the path in case it is a symlink or /. or /../
if skip_chdir if skip_chdir
&& canonicalize(newroot, MissingHandling::Normal, ResolveMode::Logical) && canonicalize(newroot, MissingHandling::Normal, ResolveMode::Logical)
@ -116,7 +116,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)
@ -168,13 +168,14 @@ pub fn uu_app<'a>() -> Command<'a> {
"Use this option to not change the working directory \ "Use this option to not change the working directory \
to / after changing the root directory to newroot, \ to / after changing the root directory to newroot, \
i.e., inside the chroot.", i.e., inside the chroot.",
), )
.action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::COMMAND) Arg::new(options::COMMAND)
.action(ArgAction::Append)
.value_hint(clap::ValueHint::CommandName) .value_hint(clap::ValueHint::CommandName)
.hide(true) .hide(true)
.multiple_occurrences(true)
.index(2), .index(2),
) )
} }