Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/uu/hostname/locales/en-US.ftl
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
hostname-about = Display or set the system's host name.
hostname-usage = hostname [OPTION]... [HOSTNAME]
hostname-help-domain = Display the name of the DNS domain if possible
hostname-help-ip-address = Display the network address(es) of the host
hostname-help-fqdn = Display the FQDN (Fully Qualified Domain Name) (default)
hostname-help-short = Display the short hostname (the portion before the first dot) if possible
hostname-error-permission = hostname: you must be root to change the host name
hostname-error-invalid-name = hostname: invalid hostname '{ $name }'
hostname-error-resolve-failed = hostname: unable to resolve host name '{ $name }'
hostname-error-winsock = failed to start Winsock
hostname-error-set-hostname = failed to set hostname
hostname-error-get-hostname = failed to get hostname
hostname-error-resolve-socket = failed to resolve socket addresses
13 changes: 13 additions & 0 deletions src/uu/hostname/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
hostname-about = Afficher ou définir le nom d'hôte du système.
hostname-usage = hostname [OPTION]... [NOM_HÔTE]
hostname-help-domain = Afficher le nom du domaine DNS si possible
hostname-help-ip-address = Afficher la ou les adresses réseau de l'hôte
hostname-help-fqdn = Afficher le FQDN (nom de domaine pleinement qualifié) (par défaut)
hostname-help-short = Afficher le nom d'hôte court (la partie avant le premier point) si possible
hostname-error-permission = hostname : vous devez être root pour changer le nom d'hôte
hostname-error-invalid-name = hostname : nom d'hôte invalide '{ $name }'
hostname-error-resolve-failed = hostname : impossible de résoudre le nom d'hôte '{ $name }'
hostname-error-winsock = échec du démarrage de Winsock
hostname-error-set-hostname = échec de la définition du nom d'hôte
hostname-error-get-hostname = échec de l'obtention du nom d'hôte
hostname-error-resolve-socket = échec de la résolution des adresses de socket
14 changes: 8 additions & 6 deletions src/uu/hostname/src/hostname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@
let matches = uu_app().try_get_matches_from(args)?;

#[cfg(windows)]
let _handle = wsa::start().map_err_context(|| "failed to start Winsock".to_owned())?;
let _handle = wsa::start().map_err_context(|| get_message("hostname-error-winsock"))?;

match matches.get_one::<OsString>(OPT_HOST) {
None => display_hostname(&matches),
Some(host) => hostname::set(host).map_err_context(|| "failed to set hostname".to_owned()),
Some(host) => {
hostname::set(host).map_err_context(|| get_message("hostname-error-set-hostname"))

Check warning on line 71 in src/uu/hostname/src/hostname.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/hostname/src/hostname.rs#L70-L71

Added lines #L70 - L71 were not covered by tests
}
}
}

Expand All @@ -82,31 +84,31 @@
.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")
.help(get_message("hostname-help-domain"))
.action(ArgAction::SetTrue),
)
.arg(
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")
.help(get_message("hostname-help-ip-address"))
.action(ArgAction::SetTrue),
)
.arg(
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)")
.help(get_message("hostname-help-fqdn"))
.action(ArgAction::SetTrue),
)
.arg(
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")
.help(get_message("hostname-help-short"))
.action(ArgAction::SetTrue),
)
.arg(
Expand Down
Loading