summaryrefslogtreecommitdiff
path: root/src/resolve-host/resolve-host.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-08-20 00:15:05 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-20 00:18:14 +0200
commitdad29dff1925a114e20d4eb7b47fca23c4f25fd7 (patch)
treee48b3cec55288b8fced0cf6076ac86e487011f58 /src/resolve-host/resolve-host.c
parentf9ffbca2fb1ba7a7854d83439a4644590be0d9e1 (diff)
cmdline: for new tools avoid introduce new negative switches, and properly align --help texts
Negative switches are a bad un-normalized thing. We alerady have some, but we should try harder to avoid intrdoucing new ones. Hence, instead of adding two switches: --foobar --no-foobar Let's instead use the syntax --foobar --foobar=yes --foobar=no Where the first two are equivalent. The boolean argument is parsed following the usual rules. Change all new negative switches this way. This patch also properly aligns the --help table, so that single char switches always get a column separate of the long switches.
Diffstat (limited to 'src/resolve-host/resolve-host.c')
-rw-r--r--src/resolve-host/resolve-host.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c
index c39b58237..49049d2a2 100644
--- a/src/resolve-host/resolve-host.c
+++ b/src/resolve-host/resolve-host.c
@@ -466,14 +466,14 @@ static void help(void) {
" -p --protocol=PROTOCOL Look via protocol\n"
" -t --type=TYPE Query RR with DNS type\n"
" -c --class=CLASS Query RR with DNS class\n"
- " --no-legend Do not print column headers\n"
+ " --legend[=BOOL] Do [not] print column headers\n"
, program_invocation_short_name);
}
static int parse_argv(int argc, char *argv[]) {
enum {
ARG_VERSION = 0x100,
- ARG_NO_LEGEND,
+ ARG_LEGEND,
};
static const struct option options[] = {
@@ -481,7 +481,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "version", no_argument, NULL, ARG_VERSION },
{ "type", required_argument, NULL, 't' },
{ "class", required_argument, NULL, 'c' },
- { "no-legend", no_argument, NULL, ARG_NO_LEGEND },
+ { "legend", optional_argument, NULL, ARG_LEGEND },
{ "protocol", required_argument, NULL, 'p' },
{}
};
@@ -548,8 +548,17 @@ static int parse_argv(int argc, char *argv[]) {
break;
- case ARG_NO_LEGEND:
- arg_legend = false;
+ case ARG_LEGEND:
+ if (optarg) {
+ r = parse_boolean(optarg);
+ if (r < 0) {
+ log_error("Failed to parse --legend= argument");
+ return r;
+ }
+
+ arg_legend = !!r;
+ } else
+ arg_legend = false;
break;
case 'p':