mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
hostname: clap 3
This commit is contained in:
parent
6876521b08
commit
82aadbf38f
2 changed files with 12 additions and 12 deletions
|
@ -15,7 +15,7 @@ edition = "2018"
|
|||
path = "src/hostname.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "2.33", features = ["wrap_help"] }
|
||||
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
|
||||
libc = "0.2.42"
|
||||
hostname = { version = "0.3", features = ["set"] }
|
||||
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["wide"] }
|
||||
|
|
|
@ -61,7 +61,7 @@ fn usage() -> String {
|
|||
#[uucore_procs::gen_uumain]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let usage = usage();
|
||||
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
|
||||
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
|
||||
|
||||
#[cfg(windows)]
|
||||
let _handle = wsa::start().map_err_context(|| "failed to start Winsock".to_owned())?;
|
||||
|
@ -72,39 +72,39 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn uu_app() -> App<'static, 'static> {
|
||||
pub fn uu_app<'a>() -> App<'a> {
|
||||
App::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about(ABOUT)
|
||||
.arg(
|
||||
Arg::with_name(OPT_DOMAIN)
|
||||
.short("d")
|
||||
Arg::new(OPT_DOMAIN)
|
||||
.short('d')
|
||||
.long("domain")
|
||||
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
||||
.help("Display the name of the DNS domain if possible"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name(OPT_IP_ADDRESS)
|
||||
.short("i")
|
||||
Arg::new(OPT_IP_ADDRESS)
|
||||
.short('i')
|
||||
.long("ip-address")
|
||||
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
||||
.help("Display the network address(es) of the host"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name(OPT_FQDN)
|
||||
.short("f")
|
||||
Arg::new(OPT_FQDN)
|
||||
.short('f')
|
||||
.long("fqdn")
|
||||
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
||||
.help("Display the FQDN (Fully Qualified Domain Name) (default)"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name(OPT_SHORT)
|
||||
.short("s")
|
||||
Arg::new(OPT_SHORT)
|
||||
.short('s')
|
||||
.long("short")
|
||||
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
||||
.help("Display the short hostname (the portion before the first dot) if possible"),
|
||||
)
|
||||
.arg(Arg::with_name(OPT_HOST))
|
||||
.arg(Arg::new(OPT_HOST).allow_invalid_utf8(true))
|
||||
}
|
||||
|
||||
fn display_hostname(matches: &ArgMatches) -> UResult<()> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue