mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
runcon: update to clap 4
This commit is contained in:
parent
634a4aab8e
commit
d92f2f6195
2 changed files with 9 additions and 12 deletions
|
@ -14,7 +14,7 @@ edition = "2021"
|
||||||
path = "src/runcon.rs"
|
path = "src/runcon.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "3.2", features = ["wrap_help", "cargo"] }
|
clap = { version = "4.0", features = ["wrap_help", "cargo"] }
|
||||||
uucore = { version = ">=0.0.9", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] }
|
uucore = { version = ">=0.0.9", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] }
|
||||||
selinux = { version = "0.3" }
|
selinux = { version = "0.3" }
|
||||||
thiserror = { version = "1.0" }
|
thiserror = { version = "1.0" }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use clap::builder::ValueParser;
|
use clap::builder::ValueParser;
|
||||||
use uucore::error::{UResult, UUsageError};
|
use uucore::error::{UResult, UUsageError};
|
||||||
|
|
||||||
use clap::{Arg, Command};
|
use clap::{Arg, ArgAction, Command};
|
||||||
use selinux::{OpaqueSecurityContext, SecurityClass, SecurityContext};
|
use selinux::{OpaqueSecurityContext, SecurityClass, SecurityContext};
|
||||||
use uucore::format_usage;
|
use uucore::format_usage;
|
||||||
|
|
||||||
|
@ -50,7 +50,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
Err(r) => {
|
Err(r) => {
|
||||||
if let Error::CommandLine(ref r) = r {
|
if let Error::CommandLine(ref r) = r {
|
||||||
match r.kind() {
|
match r.kind() {
|
||||||
clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => {
|
clap::error::ErrorKind::DisplayHelp
|
||||||
|
| clap::error::ErrorKind::DisplayVersion => {
|
||||||
println!("{}", r);
|
println!("{}", r);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -104,7 +105,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())
|
Command::new(uucore::util_name())
|
||||||
.version(VERSION)
|
.version(VERSION)
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
|
@ -115,14 +116,13 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
Arg::new(options::COMPUTE)
|
Arg::new(options::COMPUTE)
|
||||||
.short('c')
|
.short('c')
|
||||||
.long(options::COMPUTE)
|
.long(options::COMPUTE)
|
||||||
.takes_value(false)
|
.help("Compute process transition context before modifying.")
|
||||||
.help("Compute process transition context before modifying."),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::USER)
|
Arg::new(options::USER)
|
||||||
.short('u')
|
.short('u')
|
||||||
.long(options::USER)
|
.long(options::USER)
|
||||||
.takes_value(true)
|
|
||||||
.value_name("USER")
|
.value_name("USER")
|
||||||
.help("Set user USER in the target security context.")
|
.help("Set user USER in the target security context.")
|
||||||
.value_parser(ValueParser::os_string()),
|
.value_parser(ValueParser::os_string()),
|
||||||
|
@ -131,7 +131,6 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
Arg::new(options::ROLE)
|
Arg::new(options::ROLE)
|
||||||
.short('r')
|
.short('r')
|
||||||
.long(options::ROLE)
|
.long(options::ROLE)
|
||||||
.takes_value(true)
|
|
||||||
.value_name("ROLE")
|
.value_name("ROLE")
|
||||||
.help("Set role ROLE in the target security context.")
|
.help("Set role ROLE in the target security context.")
|
||||||
.value_parser(ValueParser::os_string()),
|
.value_parser(ValueParser::os_string()),
|
||||||
|
@ -140,7 +139,6 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
Arg::new(options::TYPE)
|
Arg::new(options::TYPE)
|
||||||
.short('t')
|
.short('t')
|
||||||
.long(options::TYPE)
|
.long(options::TYPE)
|
||||||
.takes_value(true)
|
|
||||||
.value_name("TYPE")
|
.value_name("TYPE")
|
||||||
.help("Set type TYPE in the target security context.")
|
.help("Set type TYPE in the target security context.")
|
||||||
.value_parser(ValueParser::os_string()),
|
.value_parser(ValueParser::os_string()),
|
||||||
|
@ -149,14 +147,13 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
Arg::new(options::RANGE)
|
Arg::new(options::RANGE)
|
||||||
.short('l')
|
.short('l')
|
||||||
.long(options::RANGE)
|
.long(options::RANGE)
|
||||||
.takes_value(true)
|
|
||||||
.value_name("RANGE")
|
.value_name("RANGE")
|
||||||
.help("Set range RANGE in the target security context.")
|
.help("Set range RANGE in the target security context.")
|
||||||
.value_parser(ValueParser::os_string()),
|
.value_parser(ValueParser::os_string()),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("ARG")
|
Arg::new("ARG")
|
||||||
.multiple_occurrences(true)
|
.action(ArgAction::Append)
|
||||||
.value_parser(ValueParser::os_string())
|
.value_parser(ValueParser::os_string())
|
||||||
.value_hint(clap::ValueHint::CommandName),
|
.value_hint(clap::ValueHint::CommandName),
|
||||||
)
|
)
|
||||||
|
@ -210,7 +207,7 @@ struct Options {
|
||||||
fn parse_command_line(config: Command, args: impl uucore::Args) -> Result<Options> {
|
fn parse_command_line(config: Command, args: impl uucore::Args) -> Result<Options> {
|
||||||
let matches = config.try_get_matches_from(args)?;
|
let matches = config.try_get_matches_from(args)?;
|
||||||
|
|
||||||
let compute_transition_context = matches.contains_id(options::COMPUTE);
|
let compute_transition_context = matches.get_flag(options::COMPUTE);
|
||||||
|
|
||||||
let mut args = matches
|
let mut args = matches
|
||||||
.get_many::<OsString>("ARG")
|
.get_many::<OsString>("ARG")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue