Skip to content

Commit dc288ff

Browse files
authored
Merge pull request systemd#18596 from keszybz/systemctl-quiet-legend
systemctl: hide legends with --quiet, allow overriding
2 parents a63b54e + d60bd2f commit dc288ff

File tree

25 files changed

+202
-239
lines changed

25 files changed

+202
-239
lines changed

man/standard-options.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@
3535
<listitem><para>Do not query the user for authentication for privileged operations.</para></listitem>
3636
</varlistentry>
3737

38+
<varlistentry id='legend'>
39+
<term><option>--legend=</option><replaceable>BOOL</replaceable></term>
40+
41+
<listitem>
42+
<para>Enable or disable printing of the legend, i.e. column headers and the footer with hints. The
43+
legend is printed by default, unless disabled with <option>--quiet</option> or similar.</para>
44+
</listitem>
45+
</varlistentry>
46+
3847
<varlistentry id='no-legend'>
3948
<term><option>--no-legend</option></term>
4049

man/systemctl.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2326,7 +2326,7 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
23262326
<xi:include href="user-system-options.xml" xpointer="machine" />
23272327

23282328
<xi:include href="standard-options.xml" xpointer="no-pager" />
2329-
<xi:include href="standard-options.xml" xpointer="no-legend" />
2329+
<xi:include href="standard-options.xml" xpointer="legend" />
23302330
<xi:include href="standard-options.xml" xpointer="help" />
23312331
<xi:include href="standard-options.xml" xpointer="version" />
23322332
</variablelist>

shell-completion/bash/systemctl.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
__systemctl() {
99
local mode=$1; shift 1
10-
systemctl $mode --full --no-legend --no-pager --plain "$@" 2>/dev/null
10+
systemctl $mode --full --legend=no --no-pager --plain "$@" 2>/dev/null
1111
}
1212

1313
__systemd_properties() {
@@ -123,7 +123,7 @@ _systemctl () {
123123

124124
local -A OPTS=(
125125
[STANDALONE]='--all -a --reverse --after --before --defaults --force -f --full -l --global
126-
--help -h --no-ask-password --no-block --no-legend --no-pager --no-reload --no-wall --now
126+
--help -h --no-ask-password --no-block --legend=no --no-pager --no-reload --no-wall --now
127127
--quiet -q --system --user --version --runtime --recursive -r --firmware-setup
128128
--show-types --plain --failed --value --fail --dry-run --wait'
129129
[ARG]='--host -H --kill-who --property -p --signal -s --type -t --state --job-mode --root

shell-completion/zsh/_systemctl.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
# @todo _systemd-run has a helper with the same name, so we must redefine
148148
__systemctl()
149149
{
150-
systemctl $_sys_service_mgr --full --no-legend --no-pager --plain "$@" 2>/dev/null
150+
systemctl $_sys_service_mgr --full --legend=no --no-pager --plain "$@" 2>/dev/null
151151
}
152152

153153

@@ -480,7 +480,7 @@ _arguments -s \
480480
'--check-inhibitors[Specify if inhibitors should be checked]:mode:_systemctl_check_inhibitors' \
481481
{-q,--quiet}'[Suppress output]' \
482482
'--no-block[Do not wait until operation finished]' \
483-
'--no-legend[Do not print a legend, i.e. the column headers and the footer with hints]' \
483+
'--legend=no[Do not print a legend, i.e. the column headers and the footer with hints]' \
484484
'--no-pager[Do not pipe output into a pager]' \
485485
'--system[Connect to system manager]' \
486486
'--user[Connect to user service manager]' \

src/analyze/analyze.c

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "main-func.h"
3838
#include "nulstr-util.h"
3939
#include "pager.h"
40+
#include "parse-argument.h"
4041
#include "parse-util.h"
4142
#include "path-util.h"
4243
#include "pretty-print.h"
@@ -2340,29 +2341,15 @@ static int parse_argv(int argc, char *argv[]) {
23402341
break;
23412342

23422343
case ARG_MAN:
2343-
if (optarg) {
2344-
r = parse_boolean(optarg);
2345-
if (r < 0)
2346-
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
2347-
"Failed to parse --man= argument.");
2348-
2349-
arg_man = r;
2350-
} else
2351-
arg_man = true;
2352-
2344+
r = parse_boolean_argument("--man", optarg, &arg_man);
2345+
if (r < 0)
2346+
return r;
23532347
break;
23542348

23552349
case ARG_GENERATORS:
2356-
if (optarg) {
2357-
r = parse_boolean(optarg);
2358-
if (r < 0)
2359-
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
2360-
"Failed to parse --generators= argument.");
2361-
2362-
arg_generators = r;
2363-
} else
2364-
arg_generators = true;
2365-
2350+
r = parse_boolean_argument("--generators", optarg, &arg_generators);
2351+
if (r < 0)
2352+
return r;
23662353
break;
23672354

23682355
case ARG_ITERATIONS:

src/busctl/busctl.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,27 +2471,22 @@ static int parse_argv(int argc, char *argv[]) {
24712471
break;
24722472

24732473
case ARG_EXPECT_REPLY:
2474-
r = parse_boolean(optarg);
2474+
r = parse_boolean_argument("--expect-reply=", optarg, &arg_expect_reply);
24752475
if (r < 0)
2476-
return log_error_errno(r, "Failed to parse --expect-reply= parameter '%s': %m", optarg);
2477-
2478-
arg_expect_reply = r;
2476+
return r;
24792477
break;
24802478

24812479
case ARG_AUTO_START:
2482-
r = parse_boolean(optarg);
2480+
r = parse_boolean_argument("--auto-start=", optarg, &arg_auto_start);
24832481
if (r < 0)
2484-
return log_error_errno(r, "Failed to parse --auto-start= parameter '%s': %m", optarg);
2485-
2486-
arg_auto_start = r;
2482+
return r;
24872483
break;
24882484

24892485
case ARG_ALLOW_INTERACTIVE_AUTHORIZATION:
2490-
r = parse_boolean(optarg);
2486+
r = parse_boolean_argument("--allow-interactive-authorization=", optarg,
2487+
&arg_allow_interactive_authorization);
24912488
if (r < 0)
2492-
return log_error_errno(r, "Failed to parse --allow-interactive-authorization= parameter '%s': %m", optarg);
2493-
2494-
arg_allow_interactive_authorization = r;
2489+
return r;
24952490
break;
24962491

24972492
case ARG_TIMEOUT:
@@ -2502,19 +2497,15 @@ static int parse_argv(int argc, char *argv[]) {
25022497
break;
25032498

25042499
case ARG_AUGMENT_CREDS:
2505-
r = parse_boolean(optarg);
2500+
r = parse_boolean_argument("--augment-creds=", optarg, &arg_augment_creds);
25062501
if (r < 0)
2507-
return log_error_errno(r, "Failed to parse --augment-creds= parameter '%s': %m", optarg);
2508-
2509-
arg_augment_creds = r;
2502+
return r;
25102503
break;
25112504

25122505
case ARG_WATCH_BIND:
2513-
r = parse_boolean(optarg);
2506+
r = parse_boolean_argument("--watch-bind=", optarg, &arg_watch_bind);
25142507
if (r < 0)
2515-
return log_error_errno(r, "Failed to parse --watch-bind= parameter '%s': %m", optarg);
2516-
2517-
arg_watch_bind = r;
2508+
return r;
25182509
break;
25192510

25202511
case 'j':

src/cgtop/cgtop.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "hashmap.h"
2020
#include "main-func.h"
2121
#include "missing_sched.h"
22+
#include "parse-argument.h"
2223
#include "parse-util.h"
2324
#include "path-util.h"
2425
#include "pretty-print.h"
@@ -867,12 +868,11 @@ static int parse_argv(int argc, char *argv[]) {
867868
break;
868869

869870
case ARG_RECURSIVE:
870-
r = parse_boolean(optarg);
871+
r = parse_boolean_argument("--recursive=", optarg, &arg_recursive);
871872
if (r < 0)
872-
return log_error_errno(r, "Failed to parse --recursive= argument '%s': %m", optarg);
873+
return r;
873874

874-
arg_recursive = r;
875-
arg_recursive_unset = r == 0;
875+
arg_recursive_unset = !r;
876876
break;
877877

878878
case 'M':

src/core/main.c

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -937,15 +937,9 @@ static int parse_argv(int argc, char *argv[]) {
937937
break;
938938

939939
case ARG_DUMP_CORE:
940-
if (!optarg)
941-
arg_dump_core = true;
942-
else {
943-
r = parse_boolean(optarg);
944-
if (r < 0)
945-
return log_error_errno(r, "Failed to parse dump core boolean: \"%s\": %m",
946-
optarg);
947-
arg_dump_core = r;
948-
}
940+
r = parse_boolean_argument("--dump-core", optarg, &arg_dump_core);
941+
if (r < 0)
942+
return r;
949943
break;
950944

951945
case ARG_CRASH_CHVT:
@@ -956,27 +950,15 @@ static int parse_argv(int argc, char *argv[]) {
956950
break;
957951

958952
case ARG_CRASH_SHELL:
959-
if (!optarg)
960-
arg_crash_shell = true;
961-
else {
962-
r = parse_boolean(optarg);
963-
if (r < 0)
964-
return log_error_errno(r, "Failed to parse crash shell boolean: \"%s\": %m",
965-
optarg);
966-
arg_crash_shell = r;
967-
}
953+
r = parse_boolean_argument("--crash-shell", optarg, &arg_crash_shell);
954+
if (r < 0)
955+
return r;
968956
break;
969957

970958
case ARG_CRASH_REBOOT:
971-
if (!optarg)
972-
arg_crash_reboot = true;
973-
else {
974-
r = parse_boolean(optarg);
975-
if (r < 0)
976-
return log_error_errno(r, "Failed to parse crash shell boolean: \"%s\": %m",
977-
optarg);
978-
arg_crash_reboot = r;
979-
}
959+
r = parse_boolean_argument("--crash-reboot", optarg, &arg_crash_reboot);
960+
if (r < 0)
961+
return r;
980962
break;
981963

982964
case ARG_CONFIRM_SPAWN:
@@ -989,11 +971,9 @@ static int parse_argv(int argc, char *argv[]) {
989971
break;
990972

991973
case ARG_SERVICE_WATCHDOGS:
992-
r = parse_boolean(optarg);
974+
r = parse_boolean_argument("--service-watchdogs=", optarg, &arg_service_watchdogs);
993975
if (r < 0)
994-
return log_error_errno(r, "Failed to parse service watchdogs boolean: \"%s\": %m",
995-
optarg);
996-
arg_service_watchdogs = r;
976+
return r;
997977
break;
998978

999979
case ARG_SHOW_STATUS:

src/delta/delta.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "main-func.h"
1616
#include "nulstr-util.h"
1717
#include "pager.h"
18+
#include "parse-argument.h"
1819
#include "parse-util.h"
1920
#include "path-util.h"
2021
#include "pretty-print.h"
@@ -586,7 +587,7 @@ static int parse_argv(int argc, char *argv[]) {
586587
{}
587588
};
588589

589-
int c;
590+
int c, r;
590591

591592
assert(argc >= 1);
592593
assert(argv);
@@ -616,18 +617,10 @@ static int parse_argv(int argc, char *argv[]) {
616617
}
617618

618619
case ARG_DIFF:
619-
if (!optarg)
620-
arg_diff = 1;
621-
else {
622-
int b;
623-
624-
b = parse_boolean(optarg);
625-
if (b < 0)
626-
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
627-
"Failed to parse diff boolean.");
628-
629-
arg_diff = b;
630-
}
620+
r = parse_boolean_argument("--diff", optarg, NULL);
621+
if (r < 0)
622+
return r;
623+
arg_diff = r;
631624
break;
632625

633626
case '?':

src/journal-remote/journal-remote-main.c

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "journal-remote.h"
1515
#include "main-func.h"
1616
#include "memory-util.h"
17+
#include "parse-argument.h"
1718
#include "pretty-print.h"
1819
#include "process-util.h"
1920
#include "rlimit-util.h"
@@ -34,8 +35,8 @@ static const char* arg_listen_raw = NULL;
3435
static const char* arg_listen_http = NULL;
3536
static const char* arg_listen_https = NULL;
3637
static char** arg_files = NULL; /* Do not free this. */
37-
static int arg_compress = true;
38-
static int arg_seal = false;
38+
static bool arg_compress = true;
39+
static bool arg_seal = false;
3940
static int http_socket = -1, https_socket = -1;
4041
static char** arg_gnutls_log = NULL;
4142

@@ -965,34 +966,20 @@ static int parse_argv(int argc, char *argv[]) {
965966
break;
966967

967968
case ARG_COMPRESS:
968-
if (optarg) {
969-
r = parse_boolean(optarg);
970-
if (r < 0)
971-
return log_error_errno(r, "Failed to parse --compress= parameter.");
972-
973-
arg_compress = !!r;
974-
} else
975-
arg_compress = true;
976-
969+
r = parse_boolean_argument("--compress", optarg, &arg_compress);
970+
if (r < 0)
971+
return r;
977972
break;
978973

979974
case ARG_SEAL:
980-
if (optarg) {
981-
r = parse_boolean(optarg);
982-
if (r < 0)
983-
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
984-
"Failed to parse --seal= parameter.");
985-
986-
arg_seal = !!r;
987-
} else
988-
arg_seal = true;
989-
975+
r = parse_boolean_argument("--seal", optarg, &arg_seal);
976+
if (r < 0)
977+
return r;
990978
break;
991979

992-
case ARG_GNUTLS_LOG: {
980+
case ARG_GNUTLS_LOG:
993981
#if HAVE_GNUTLS
994-
const char* p = optarg;
995-
for (;;) {
982+
for (const char* p = optarg;;) {
996983
_cleanup_free_ char *word = NULL;
997984

998985
r = extract_first_word(&p, &word, ",", 0);
@@ -1011,7 +998,6 @@ static int parse_argv(int argc, char *argv[]) {
1011998
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
1012999
"Option --gnutls-log is not available.");
10131000
#endif
1014-
}
10151001

10161002
case '?':
10171003
return -EINVAL;

0 commit comments

Comments
 (0)