mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +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"
|
path = "src/hostname.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "2.33", features = ["wrap_help"] }
|
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
|
||||||
libc = "0.2.42"
|
libc = "0.2.42"
|
||||||
hostname = { version = "0.3", features = ["set"] }
|
hostname = { version = "0.3", features = ["set"] }
|
||||||
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["wide"] }
|
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["wide"] }
|
||||||
|
|
|
@ -61,7 +61,7 @@ fn usage() -> String {
|
||||||
#[uucore_procs::gen_uumain]
|
#[uucore_procs::gen_uumain]
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let usage = usage();
|
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)]
|
#[cfg(windows)]
|
||||||
let _handle = wsa::start().map_err_context(|| "failed to start Winsock".to_owned())?;
|
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())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(OPT_DOMAIN)
|
Arg::new(OPT_DOMAIN)
|
||||||
.short("d")
|
.short('d')
|
||||||
.long("domain")
|
.long("domain")
|
||||||
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
||||||
.help("Display the name of the DNS domain if possible"),
|
.help("Display the name of the DNS domain if possible"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(OPT_IP_ADDRESS)
|
Arg::new(OPT_IP_ADDRESS)
|
||||||
.short("i")
|
.short('i')
|
||||||
.long("ip-address")
|
.long("ip-address")
|
||||||
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
||||||
.help("Display the network address(es) of the host"),
|
.help("Display the network address(es) of the host"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(OPT_FQDN)
|
Arg::new(OPT_FQDN)
|
||||||
.short("f")
|
.short('f')
|
||||||
.long("fqdn")
|
.long("fqdn")
|
||||||
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
||||||
.help("Display the FQDN (Fully Qualified Domain Name) (default)"),
|
.help("Display the FQDN (Fully Qualified Domain Name) (default)"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(OPT_SHORT)
|
Arg::new(OPT_SHORT)
|
||||||
.short("s")
|
.short('s')
|
||||||
.long("short")
|
.long("short")
|
||||||
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_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"),
|
.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<()> {
|
fn display_hostname(matches: &ArgMatches) -> UResult<()> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue