summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/systemctl/systemctl-list-jobs.c6
-rw-r--r--src/systemctl/systemctl-list-machines.c4
-rw-r--r--src/systemctl/systemctl-list-unit-files.c4
-rw-r--r--src/systemctl/systemctl-list-units.c12
-rw-r--r--src/systemctl/systemctl.c61
-rw-r--r--src/systemctl/systemctl.h2
6 files changed, 51 insertions, 38 deletions
diff --git a/src/systemctl/systemctl-list-jobs.c b/src/systemctl/systemctl-list-jobs.c
index 8b028c013a..62d99671a5 100644
--- a/src/systemctl/systemctl-list-jobs.c
+++ b/src/systemctl/systemctl-list-jobs.c
@@ -65,7 +65,7 @@ static int output_jobs_list(sd_bus *bus, const struct job_info* jobs, unsigned n
assert(n == 0 || jobs);
if (n == 0) {
- if (!arg_no_legend) {
+ if (arg_legend != 0) {
on = ansi_highlight_green();
off = ansi_normal();
@@ -80,7 +80,7 @@ static int output_jobs_list(sd_bus *bus, const struct job_info* jobs, unsigned n
if (!table)
return log_oom();
- table_set_header(table, !arg_no_legend);
+ table_set_header(table, arg_legend != 0);
if (arg_full)
table_set_width(table, 0);
@@ -112,7 +112,7 @@ static int output_jobs_list(sd_bus *bus, const struct job_info* jobs, unsigned n
if (r < 0)
return log_error_errno(r, "Failed to print the table: %m");
- if (!arg_no_legend) {
+ if (arg_legend != 0) {
on = ansi_highlight();
off = ansi_normal();
diff --git a/src/systemctl/systemctl-list-machines.c b/src/systemctl/systemctl-list-machines.c
index 48d0e8bde4..712ee8a86b 100644
--- a/src/systemctl/systemctl-list-machines.c
+++ b/src/systemctl/systemctl-list-machines.c
@@ -160,7 +160,7 @@ static int output_machines_list(struct machine_info *machine_infos, unsigned n)
if (!table)
return log_oom();
- table_set_header(table, !arg_no_legend);
+ table_set_header(table, arg_legend != 0);
if (arg_plain) {
/* Hide the 'glyph' column when --plain is requested */
r = table_hide_column_from_display(table, 0);
@@ -213,7 +213,7 @@ static int output_machines_list(struct machine_info *machine_infos, unsigned n)
if (r < 0)
return r;
- if (!arg_no_legend) {
+ if (arg_legend != 0) {
printf("\n");
if (state_missing && geteuid() != 0)
printf("Notice: some information only available to privileged users was not shown.\n");
diff --git a/src/systemctl/systemctl-list-unit-files.c b/src/systemctl/systemctl-list-unit-files.c
index e1bf876620..95911172a3 100644
--- a/src/systemctl/systemctl-list-unit-files.c
+++ b/src/systemctl/systemctl-list-unit-files.c
@@ -58,7 +58,7 @@ static int output_unit_file_list(const UnitFileList *units, unsigned c) {
if (!table)
return log_oom();
- table_set_header(table, !arg_no_legend);
+ table_set_header(table, arg_legend != 0);
if (arg_full)
table_set_width(table, 0);
@@ -127,7 +127,7 @@ static int output_unit_file_list(const UnitFileList *units, unsigned c) {
if (r < 0)
return r;
- if (!arg_no_legend)
+ if (arg_legend != 0)
printf("\n%u unit files listed.\n", c);
return 0;
diff --git a/src/systemctl/systemctl-list-units.c b/src/systemctl/systemctl-list-units.c
index 7f0e79eedd..4106c2b1a4 100644
--- a/src/systemctl/systemctl-list-units.c
+++ b/src/systemctl/systemctl-list-units.c
@@ -97,7 +97,7 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) {
if (!table)
return log_oom();
- table_set_header(table, !arg_no_legend);
+ table_set_header(table, arg_legend != 0);
if (arg_plain) {
/* Hide the 'glyph' column when --plain is requested */
r = table_hide_column_from_display(table, 0);
@@ -177,7 +177,7 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) {
if (r < 0)
return r;
- if (!arg_no_legend) {
+ if (arg_legend != 0) {
const char *on, *off;
size_t records = table_get_rows(table) - 1;
@@ -366,7 +366,7 @@ static int output_sockets_list(struct socket_info *socket_infos, unsigned cs) {
return log_error_errno(r, "Failed to set columns to display: %m");
}
- table_set_header(table, !arg_no_legend);
+ table_set_header(table, arg_legend != 0);
if (arg_full)
table_set_width(table, 0);
@@ -417,7 +417,7 @@ static int output_sockets_list(struct socket_info *socket_infos, unsigned cs) {
if (r < 0)
return r;
- if (!arg_no_legend) {
+ if (arg_legend != 0) {
printf("\n%s%u sockets listed.%s\n", on, cs, off);
if (!arg_all)
printf("Pass --all to see loaded but inactive sockets, too.\n");
@@ -614,7 +614,7 @@ static int output_timers_list(struct timer_info *timer_infos, unsigned n) {
if (!table)
return log_oom();
- table_set_header(table, !arg_no_legend);
+ table_set_header(table, arg_legend != 0);
if (arg_full)
table_set_width(table, 0);
@@ -659,7 +659,7 @@ static int output_timers_list(struct timer_info *timer_infos, unsigned n) {
if (r < 0)
return r;
- if (!arg_no_legend) {
+ if (arg_legend != 0) {
printf("\n%s%u timers listed.%s\n", on, n, off);
if (!arg_all)
printf("Pass --all to see loaded but inactive timers, too.\n");
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 08a54a469e..f3a784db33 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -68,7 +68,7 @@ const char *arg_job_mode = "replace";
UnitFileScope arg_scope = UNIT_FILE_SYSTEM;
bool arg_wait = false;
bool arg_no_block = false;
-bool arg_no_legend = false;
+int arg_legend = -1; /* -1: true, unless --quiet is passed, 1: true */
PagerFlags arg_pager_flags = 0;
bool arg_no_wtmp = false;
bool arg_no_sync = false;
@@ -267,7 +267,7 @@ static int systemctl_help(void) {
" --no-block Do not wait until operation finished\n"
" --no-wall Don't send wall message before halt/power-off/reboot\n"
" --no-reload Don't reload daemon after en-/dis-abling unit files\n"
- " --no-legend Do not print a legend (column headers and hints)\n"
+ " --legend=BOOL Enable/disable the legend (column headers and hints)\n"
" --no-pager Do not pipe output into a pager\n"
" --no-ask-password Do not ask for system passwords\n"
" --global Enable/disable/mask unit files globally\n"
@@ -308,88 +308,89 @@ static int systemctl_help(void) {
}
static void help_types(void) {
- if (!arg_no_legend)
+ if (arg_legend != 0)
puts("Available unit types:");
DUMP_STRING_TABLE(unit_type, UnitType, _UNIT_TYPE_MAX);
}
static void help_states(void) {
- if (!arg_no_legend)
+ if (arg_legend != 0)
puts("Available unit load states:");
DUMP_STRING_TABLE(unit_load_state, UnitLoadState, _UNIT_LOAD_STATE_MAX);
- if (!arg_no_legend)
+ if (arg_legend != 0)
puts("\nAvailable unit active states:");
DUMP_STRING_TABLE(unit_active_state, UnitActiveState, _UNIT_ACTIVE_STATE_MAX);
- if (!arg_no_legend)
+ if (arg_legend != 0)
puts("\nAvailable unit file states:");
DUMP_STRING_TABLE(unit_file_state, UnitFileState, _UNIT_FILE_STATE_MAX);
- if (!arg_no_legend)
+ if (arg_legend != 0)
puts("\nAvailable automount unit substates:");
DUMP_STRING_TABLE(automount_state, AutomountState, _AUTOMOUNT_STATE_MAX);
- if (!arg_no_legend)
+ if (arg_legend != 0)
puts("\nAvailable device unit substates:");
DUMP_STRING_TABLE(device_state, DeviceState, _DEVICE_STATE_MAX);
- if (!arg_no_legend)
+ if (arg_legend != 0)
puts("\nAvailable mount unit substates:");
DUMP_STRING_TABLE(mount_state, MountState, _MOUNT_STATE_MAX);
- if (!arg_no_legend)
+ if (arg_legend != 0)
puts("\nAvailable path unit substates:");
DUMP_STRING_TABLE(path_state, PathState, _PATH_STATE_MAX);
- if (!arg_no_legend)
+ if (arg_legend != 0)
puts("\nAvailable scope unit substates:");
DUMP_STRING_TABLE(scope_state, ScopeState, _SCOPE_STATE_MAX);
- if (!arg_no_legend)
+ if (arg_legend != 0)
puts("\nAvailable service unit substates:");
DUMP_STRING_TABLE(service_state, ServiceState, _SERVICE_STATE_MAX);
- if (!arg_no_legend)
+ if (arg_legend != 0)
puts("\nAvailable slice unit substates:");
DUMP_STRING_TABLE(slice_state, SliceState, _SLICE_STATE_MAX);
- if (!arg_no_legend)
+ if (arg_legend != 0)
puts("\nAvailable socket unit substates:");
DUMP_STRING_TABLE(socket_state, SocketState, _SOCKET_STATE_MAX);
- if (!arg_no_legend)
+ if (arg_legend != 0)
puts("\nAvailable swap unit substates:");
DUMP_STRING_TABLE(swap_state, SwapState, _SWAP_STATE_MAX);
- if (!arg_no_legend)
+ if (arg_legend != 0)
puts("\nAvailable target unit substates:");
DUMP_STRING_TABLE(target_state, TargetState, _TARGET_STATE_MAX);
- if (!arg_no_legend)
+ if (arg_legend != 0)
puts("\nAvailable timer unit substates:");
DUMP_STRING_TABLE(timer_state, TimerState, _TIMER_STATE_MAX);
}
static int systemctl_parse_argv(int argc, char *argv[]) {
enum {
- ARG_FAIL = 0x100,
+ ARG_FAIL = 0x100, /* compatibility only */
ARG_REVERSE,
ARG_AFTER,
ARG_BEFORE,
ARG_CHECK_INHIBITORS,
ARG_DRY_RUN,
ARG_SHOW_TYPES,
- ARG_IRREVERSIBLE,
- ARG_IGNORE_DEPENDENCIES,
+ ARG_IRREVERSIBLE, /* compatibility only */
+ ARG_IGNORE_DEPENDENCIES, /* compatibility only */
ARG_VALUE,
ARG_VERSION,
ARG_USER,
ARG_SYSTEM,
ARG_GLOBAL,
ARG_NO_BLOCK,
- ARG_NO_LEGEND,
+ ARG_LEGEND,
+ ARG_NO_LEGEND, /* compatibility only */
ARG_NO_PAGER,
ARG_NO_WALL,
ARG_ROOT,
@@ -440,7 +441,8 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
{ "global", no_argument, NULL, ARG_GLOBAL },
{ "wait", no_argument, NULL, ARG_WAIT },
{ "no-block", no_argument, NULL, ARG_NO_BLOCK },
- { "no-legend", no_argument, NULL, ARG_NO_LEGEND },
+ { "legend", required_argument, NULL, ARG_LEGEND },
+ { "no-legend", no_argument, NULL, ARG_NO_LEGEND }, /* compatibility only */
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
{ "no-wall", no_argument, NULL, ARG_NO_WALL },
{ "dry-run", no_argument, NULL, ARG_DRY_RUN },
@@ -626,7 +628,14 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
break;
case ARG_NO_LEGEND:
- arg_no_legend = true;
+ arg_legend = false;
+ break;
+
+ case ARG_LEGEND:
+ r = parse_boolean_argument("--legend", optarg, NULL);
+ if (r < 0)
+ return r;
+ arg_legend = r;
break;
case ARG_NO_PAGER:
@@ -659,6 +668,10 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
case 'q':
arg_quiet = true;
+
+ if (arg_legend < 0)
+ arg_legend = false;
+
break;
case 'f':
@@ -717,7 +730,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
optarg);
if (OUTPUT_MODE_IS_JSON(arg_output)) {
- arg_no_legend = true;
+ arg_legend = false;
arg_plain = true;
}
break;
diff --git a/src/systemctl/systemctl.h b/src/systemctl/systemctl.h
index 0ebe4580c6..de463db9d5 100644
--- a/src/systemctl/systemctl.h
+++ b/src/systemctl/systemctl.h
@@ -52,7 +52,7 @@ extern const char *arg_job_mode;
extern UnitFileScope arg_scope;
extern bool arg_wait;
extern bool arg_no_block;
-extern bool arg_no_legend;
+extern int arg_legend;
extern PagerFlags arg_pager_flags;
extern bool arg_no_wtmp;
extern bool arg_no_sync;