mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
systemctl: hide legends with --quiet, allow overriding
--no-legend is replaced by --legend=no. --quiet now implies --legend=no, but --legend=yes may be used to override that. --quiet controls hints and warnings and such, and --legend controls just the legends. I think it makes sense to allow both to controlled independently, in particular --quiet --legend makes sense when using systemctl in a script to provide some user-visible output. Fixes #18560.
This commit is contained in:
parent
b01031e3ff
commit
6906da2692
@ -35,6 +35,15 @@
|
||||
<listitem><para>Do not query the user for authentication for privileged operations.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id='legend'>
|
||||
<term><option>--legend=</option><replaceable>BOOL</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>Enable or disable printing of the legend, i.e. column headers and the footer with hints. The
|
||||
legend is printed by default, unless disabled with <option>--quiet</option> or similar.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id='no-legend'>
|
||||
<term><option>--no-legend</option></term>
|
||||
|
||||
|
@ -2314,7 +2314,7 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
|
||||
<xi:include href="user-system-options.xml" xpointer="machine" />
|
||||
|
||||
<xi:include href="standard-options.xml" xpointer="no-pager" />
|
||||
<xi:include href="standard-options.xml" xpointer="no-legend" />
|
||||
<xi:include href="standard-options.xml" xpointer="legend" />
|
||||
<xi:include href="standard-options.xml" xpointer="help" />
|
||||
<xi:include href="standard-options.xml" xpointer="version" />
|
||||
</variablelist>
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user