Consistently use -arg=val in --help usage

This commit is contained in:
Richard Hansen 2024-03-17 13:31:51 -07:00
parent fc4daae0cd
commit 6ac1ee45b0

View file

@ -370,12 +370,12 @@ sub ip_strategies_usage {
my %ipv4_strategies = ( my %ipv4_strategies = (
'disabled' => ": do not obtain an IPv4 address for this host", 'disabled' => ": do not obtain an IPv4 address for this host",
'ipv4' => ": obtain IPv4 from -ipv4 <address>", 'ipv4' => ": obtain IPv4 from -ipv4=<address>",
'webv4' => ": obtain IPv4 from an IP discovery page on the web", 'webv4' => ": obtain IPv4 from an IP discovery page on the web",
'ifv4' => ": obtain IPv4 from the -ifv4 <interface>", 'ifv4' => ": obtain IPv4 from the -ifv4=<interface>",
'cmdv4' => ": obtain IPv4 from the -cmdv4 <external-command>", 'cmdv4' => ": obtain IPv4 from the -cmdv4=<external-command>",
'fwv4' => ": obtain IPv4 from the firewall specified by -fwv4 <type|address>", 'fwv4' => ": obtain IPv4 from the firewall specified by -fwv4=<type|address>",
map { $_ => sprintf ": obtain IPv4 from %s at the -fwv4 <address>", $builtinfw{$_}->{'name'} } keys %builtinfw, map { $_ => sprintf ": obtain IPv4 from %s at the -fwv4=<address>", $builtinfw{$_}->{'name'} } keys %builtinfw,
); );
sub ipv4_strategies_usage { sub ipv4_strategies_usage {
return map { sprintf(" -usev4=%-22s %s.", $_, $ipv4_strategies{$_}) } sort keys %ipv4_strategies; return map { sprintf(" -usev4=%-22s %s.", $_, $ipv4_strategies{$_}) } sort keys %ipv4_strategies;
@ -385,14 +385,14 @@ my %ipv6_strategies = (
'no' => ": deprecated, use 'disabled'", 'no' => ": deprecated, use 'disabled'",
'disabled' => ": do not obtain an IPv6 address for this host", 'disabled' => ": do not obtain an IPv6 address for this host",
'ip' => ": deprecated, use 'ipv6'", 'ip' => ": deprecated, use 'ipv6'",
'ipv6' => ": obtain IPv6 from -ipv6 <address>", 'ipv6' => ": obtain IPv6 from -ipv6=<address>",
'web' => ": deprecated, use 'webv6'", 'web' => ": deprecated, use 'webv6'",
'webv6' => ": obtain IPv6 from an IP discovery page on the web", 'webv6' => ": obtain IPv6 from an IP discovery page on the web",
'if' => ": deprecated, use 'ifv6'", 'if' => ": deprecated, use 'ifv6'",
'ifv6' => ": obtain IPv6 from the -if <interface>", 'ifv6' => ": obtain IPv6 from the -if=<interface>",
'cmd' => ": deprecated, use 'cmdv6'", 'cmd' => ": deprecated, use 'cmdv6'",
'cmdv6' => ": obtain IPv6 from the -cmdv6 <external-command>", 'cmdv6' => ": obtain IPv6 from the -cmdv6=<external-command>",
'fwv6' => ": obtain IPv6 from the firewall specified by -fwv6 <type|address>", 'fwv6' => ": obtain IPv6 from the firewall specified by -fwv6=<type|address>",
); );
sub ipv6_strategies_usage { sub ipv6_strategies_usage {
return map { sprintf(" -usev6=%-22s %s.", $_, $ipv6_strategies{$_}) } sort keys %ipv6_strategies; return map { sprintf(" -usev6=%-22s %s.", $_, $ipv6_strategies{$_}) } sort keys %ipv6_strategies;
@ -1009,79 +1009,79 @@ $opt{'list-web-services'} = sub {
my @opt = ( my @opt = (
"usage: ${program} [options]", "usage: ${program} [options]",
"options are:", "options are:",
["daemon", "=s", "-daemon <delay> : run as a daemon, specify <delay> as an interval"], ["daemon", "=s", "-daemon=<delay> : run as a daemon, specify <delay> as an interval"],
["foreground", "!", "-foreground : do not fork"], ["foreground", "!", "-foreground : do not fork"],
["proxy", "=s", "-proxy <host> : use <host> as the HTTP proxy"], ["proxy", "=s", "-proxy=<host> : use <host> as the HTTP proxy"],
["server", "=s", "-server <host> : update DNS information on <host>"], ["server", "=s", "-server=<host> : update DNS information on <host>"],
["protocol", "=s", "-protocol <type> : update protocol used"], ["protocol", "=s", "-protocol=<type> : update protocol used"],
["list-protocols", "", "-list-protocols : print a machine-readable list of supported update protocols and exit. Format: one per line"], ["list-protocols", "", "-list-protocols : print a machine-readable list of supported update protocols and exit. Format: one per line"],
["file", "=s", "-file <path> : load configuration information from <path>"], ["file", "=s", "-file=<path> : load configuration information from <path>"],
["cache", "=s", "-cache <path> : record address used in <path>"], ["cache", "=s", "-cache=<path> : record address used in <path>"],
["pid", "=s", "-pid <path> : record process id in <path> if daemonized"], ["pid", "=s", "-pid=<path> : record process id in <path> if daemonized"],
"", "",
["use", "=s", "-use <which> : deprecated, see 'usev4' and 'usev6'"], ["use", "=s", "-use=<which> : deprecated, see 'usev4' and 'usev6'"],
&ip_strategies_usage(), &ip_strategies_usage(),
["usev4", "=s", "-usev4 <which> : how the should IPv4 address be obtained."], ["usev4", "=s", "-usev4=<which> : how the should IPv4 address be obtained."],
&ipv4_strategies_usage(), &ipv4_strategies_usage(),
["usev6", "=s", "-usev6 <which> : how the should IPv6 address be obtained."], ["usev6", "=s", "-usev6=<which> : how the should IPv6 address be obtained."],
&ipv6_strategies_usage(), &ipv6_strategies_usage(),
"", "",
" Options that apply to 'use=ip':", " Options that apply to 'use=ip':",
["ip", "=s", "-ip <address> : deprecated, use 'ipv4' or 'ipv6'"], ["ip", "=s", "-ip=<address> : deprecated, use 'ipv4' or 'ipv6'"],
["ipv4", "=s", "-ipv4 <address> : set the IPv4 address to <address>"], ["ipv4", "=s", "-ipv4=<address> : set the IPv4 address to <address>"],
["ipv6", "=s", "-ipv6 <address> : set the IPv6 address to <address>"], ["ipv6", "=s", "-ipv6=<address> : set the IPv6 address to <address>"],
"", "",
" Options that apply to 'use=if':", " Options that apply to 'use=if':",
["if", "=s", "-if <interface> : deprecated, use 'ifv4' or 'ifv6'"], ["if", "=s", "-if=<interface> : deprecated, use 'ifv4' or 'ifv6'"],
["ifv4", "=s", "-ifv4 <interface> : obtain IPv4 address from <interface>"], ["ifv4", "=s", "-ifv4=<interface> : obtain IPv4 address from <interface>"],
["ifv6", "=s", "-ifv6 <interface> : obtain IPv6 address from <interface>"], ["ifv6", "=s", "-ifv6=<interface> : obtain IPv6 address from <interface>"],
"", "",
" Options that apply to 'use=web':", " Options that apply to 'use=web':",
["web", "=s", "-web <service|url> : deprecated, use 'webv4' or 'webv6'"], ["web", "=s", "-web=<service|url> : deprecated, use 'webv4' or 'webv6'"],
["web-skip", "=s", "-web-skip <pattern> : deprecated, use 'webv4-skip' or 'webv6-skip'"], ["web-skip", "=s", "-web-skip=<pattern> : deprecated, use 'webv4-skip' or 'webv6-skip'"],
["webv4", "=s", "-webv4 <service|url> : obtain IPv4 address from a web-based IP discovery service, either a known <service> or a custom <url>"], ["webv4", "=s", "-webv4=<service|url> : obtain IPv4 address from a web-based IP discovery service, either a known <service> or a custom <url>"],
["webv4-skip", "=s", "-webv4-skip <pattern> : skip any IP addresses before <pattern> in the output of 'ip address show dev <interface>' (or 'ifconfig <interface>')"], ["webv4-skip", "=s", "-webv4-skip=<pattern> : skip any IP addresses before <pattern> in the output of 'ip address show dev <interface>' (or 'ifconfig <interface>')"],
["webv6", "=s", "-webv6 <service|url> : obtain IPv6 address from a web-based IP discovery service, either a known <service> or a custom <url>"], ["webv6", "=s", "-webv6=<service|url> : obtain IPv6 address from a web-based IP discovery service, either a known <service> or a custom <url>"],
["webv6-skip", "=s", "-webv6-skip <pattern> : skip any IP addresses before <pattern> in the output of 'ip address show dev <interface>' (or 'ifconfig <interface>')"], ["webv6-skip", "=s", "-webv6-skip=<pattern> : skip any IP addresses before <pattern> in the output of 'ip address show dev <interface>' (or 'ifconfig <interface>')"],
["list-web-services", "", "-list-web-services : print a machine-readable list of web-based IP discovery services for use with 'web=<service>' and exit. Format: one service per line, each line has the form '<service> <url>'"], ["list-web-services", "", "-list-web-services : print a machine-readable list of web-based IP discovery services for use with 'web=<service>' and exit. Format: one service per line, each line has the form '<service> <url>'"],
"", "",
" Options that apply to 'use=fw' and 'use=<device>':", " Options that apply to 'use=fw' and 'use=<device>':",
["fw", "=s", "-fw <address|url> : deprecated, use 'fwv4' or 'fwv6'"], ["fw", "=s", "-fw=<address|url> : deprecated, use 'fwv4' or 'fwv6'"],
["fw-skip", "=s", "-fw-skip <pattern> : deprecated, use 'fwv4-skip' or 'fwv6-skip'"], ["fw-skip", "=s", "-fw-skip=<pattern> : deprecated, use 'fwv4-skip' or 'fwv6-skip'"],
["fwv4", "=s", "-fwv4 <address|url> : obtain IPv4 address from device with IP address <address> or URL <url>"], ["fwv4", "=s", "-fwv4=<address|url> : obtain IPv4 address from device with IP address <address> or URL <url>"],
["fwv4-skip", "=s", "-fwv4-skip <pattern> : skip any IP addresses before <pattern> in the text returned from the device"], ["fwv4-skip", "=s", "-fwv4-skip=<pattern> : skip any IP addresses before <pattern> in the text returned from the device"],
["fwv6", "=s", "-fwv6 <address|url> : obtain IPv6 address from device with IP address <address> or URL <url>"], ["fwv6", "=s", "-fwv6=<address|url> : obtain IPv6 address from device with IP address <address> or URL <url>"],
["fwv6-skip", "=s", "-fwv6-skip <pattern> : skip any IP addresses before <pattern> in the text returned from the device"], ["fwv6-skip", "=s", "-fwv6-skip=<pattern> : skip any IP addresses before <pattern> in the text returned from the device"],
["fw-login", "=s", "-fw-login <login> : use <login> when getting the IP from the device"], ["fw-login", "=s", "-fw-login=<login> : use <login> when getting the IP from the device"],
["fw-password", "=s", "-fw-password <secret> : use password <secret> when getting the IP from the device"], ["fw-password", "=s", "-fw-password=<secret> : use password <secret> when getting the IP from the device"],
["list-devices", "", "-list-devices : print a machine-readable list of supported firewall/router devices and exit. Format: one device per line, each line has the form '<device> <description>'"], ["list-devices", "", "-list-devices : print a machine-readable list of supported firewall/router devices and exit. Format: one device per line, each line has the form '<device> <description>'"],
"", "",
" Options that apply to 'use=cmd':", " Options that apply to 'use=cmd':",
["cmd", "=s", "-cmd <command> : deprecated, use 'cmdv4' or 'cmdv6'"], ["cmd", "=s", "-cmd=<command> : deprecated, use 'cmdv4' or 'cmdv6'"],
["cmd-skip", "=s", "-cmd-skip <pattern> : deprecated, filter in program wrapper script"], ["cmd-skip", "=s", "-cmd-skip=<pattern> : deprecated, filter in program wrapper script"],
["cmdv4", "=s", "-cmdv4 <command> : obtain IPv4 address from the output of <command>"], ["cmdv4", "=s", "-cmdv4=<command> : obtain IPv4 address from the output of <command>"],
["cmdv6", "=s", "-cmdv6 <command> : obtain IPv6 address from the output of <command>"], ["cmdv6", "=s", "-cmdv6=<command> : obtain IPv6 address from the output of <command>"],
"", "",
["login", "=s", "-login <user> : log in to the dynamic DNS service as <user>"], ["login", "=s", "-login=<user> : log in to the dynamic DNS service as <user>"],
["password", "=s", "-password <secret> : log in to the dynamic DNS service with password <secret>"], ["password", "=s", "-password=<secret> : log in to the dynamic DNS service with password <secret>"],
["host", "=s", "-host <host> : update DNS information for <host>"], ["host", "=s", "-host=<host> : update DNS information for <host>"],
"", "",
["options", "=s", "-options <opt>=<val>[,<opt>=<val>,...]\n : optional per-service arguments (see below)"], ["options", "=s", "-options=<opt>=<val>[,<opt>=<val>,...]\n : optional per-service arguments (see below)"],
"", "",
["ssl", "!", "-{no}ssl : do updates over encrypted SSL connection"], ["ssl", "!", "-{no}ssl : do updates over encrypted SSL connection"],
["ssl_ca_dir", "=s", "-ssl_ca_dir <dir> : look in <dir> for certificates of trusted certificate authorities (default: auto-detect)"], ["ssl_ca_dir", "=s", "-ssl_ca_dir=<dir> : look in <dir> for certificates of trusted certificate authorities (default: auto-detect)"],
["ssl_ca_file", "=s", "-ssl_ca_file <file> : look at <file> for certificates of trusted certificate authorities (default: auto-detect)"], ["ssl_ca_file", "=s", "-ssl_ca_file=<file> : look at <file> for certificates of trusted certificate authorities (default: auto-detect)"],
["fw-ssl-validate", "!", "-{no}fw-ssl-validate : Validate SSL certificate when retrieving IP address from firewall"], ["fw-ssl-validate", "!", "-{no}fw-ssl-validate : Validate SSL certificate when retrieving IP address from firewall"],
["web-ssl-validate", "!", "-{no}web-ssl-validate : Validate SSL certificate when retrieving IP address from web"], ["web-ssl-validate", "!", "-{no}web-ssl-validate : Validate SSL certificate when retrieving IP address from web"],
["retry", "!", "-{no}retry : retry failed updates"], ["retry", "!", "-{no}retry : retry failed updates"],
["force", "!", "-{no}force : force an update even if the update may be unnecessary"], ["force", "!", "-{no}force : force an update even if the update may be unnecessary"],
["timeout", "=i", "-timeout <max> : when fetching a URL, wait at most <max> seconds for a response"], ["timeout", "=i", "-timeout=<max> : when fetching a URL, wait at most <max> seconds for a response"],
["syslog", "!", "-{no}syslog : log messages to syslog"], ["syslog", "!", "-{no}syslog : log messages to syslog"],
["facility", "=s", "-facility <type> : log messages to syslog to facility <type>"], ["facility", "=s", "-facility=<type> : log messages to syslog to facility <type>"],
["priority", "=s", "-priority <pri> : log messages to syslog with priority <pri>"], ["priority", "=s", "-priority=<pri> : log messages to syslog with priority <pri>"],
["max-warn", "=i", "-max-warn <max> : log at most <max> warning messages for undefined IP address"], ["max-warn", "=i", "-max-warn=<max> : log at most <max> warning messages for undefined IP address"],
["mail", "=s", "-mail <address> : e-mail messages to <address>"], ["mail", "=s", "-mail=<address> : e-mail messages to <address>"],
["mail-failure", "=s", "-mail-failure <addr> : e-mail messages for failed updates to <addr>"], ["mail-failure", "=s", "-mail-failure=<addr> : e-mail messages for failed updates to <addr>"],
["exec", "!", "-{no}exec : do {not} execute; just show what would be done"], ["exec", "!", "-{no}exec : do {not} execute; just show what would be done"],
["debug", "!", "-{no}debug : print {no} debugging information"], ["debug", "!", "-{no}debug : print {no} debugging information"],
["verbose", "!", "-{no}verbose : print {no} verbose information"], ["verbose", "!", "-{no}verbose : print {no} verbose information"],
@ -1094,7 +1094,7 @@ my @opt = (
["if-skip", "=s", ""], ## deprecated ["if-skip", "=s", ""], ## deprecated
["test", "!", ""], ## hidden ["test", "!", ""], ## hidden
["geturl", "=s", ""], ## hidden ["geturl", "=s", ""], ## hidden
["redirect", "=i", "-redirect <max> : enable and follow at most <max> HTTP 30x redirections"], ["redirect", "=i", "-redirect=<max> : enable and follow at most <max> HTTP 30x redirections"],
"", "",
nic_examples(), nic_examples(),
# Note: These lines are copied below to the -version argument implementation # Note: These lines are copied below to the -version argument implementation
@ -1170,10 +1170,10 @@ sub main {
read_cache(opt('cache'), \%cache); read_cache(opt('cache'), \%cache);
print_info() if opt('debug') && opt('verbose'); print_info() if opt('debug') && opt('verbose');
fatal("invalid argument '-use %s'; possible values are:\n%s", $opt{'use'}, join("\n", ip_strategies_usage())) fatal("invalid argument '-use=%s'; possible values are:\n%s", $opt{'use'}, join("\n", ip_strategies_usage()))
unless exists $ip_strategies{lc opt('use')}; unless exists $ip_strategies{lc opt('use')};
if (defined($opt{'usev6'})) { if (defined($opt{'usev6'})) {
usage("invalid argument '-usev6 %s'; possible values are:\n%s", $opt{'usev6'}, join("\n",ipv6_strategies_usage())) usage("invalid argument '-usev6=%s'; possible values are:\n%s", $opt{'usev6'}, join("\n",ipv6_strategies_usage()))
unless exists $ipv6_strategies{lc opt('usev6')}; unless exists $ipv6_strategies{lc opt('usev6')};
} }