A batch of conversions to COMMAND struct and additions of --introspect-cli (#43394)

This commit is contained in:
Yu Watanabe
2026-08-16 04:28:05 +09:00
committed by GitHub
22 changed files with 328 additions and 631 deletions
+1 -1
View File
@@ -31,7 +31,7 @@
<command>systemd-cgls</command>
<arg choice="opt" rep="repeat">OPTIONS</arg>
<arg choice="plain"><option>--unit</option>|<option>--user-unit</option></arg>
<arg choice="opt" rep="repeat">UNIT</arg>
<arg choice="plain" rep="repeat">UNIT</arg>
</cmdsynopsis>
</refsynopsisdiv>
+6 -1
View File
@@ -25,7 +25,12 @@
<cmdsynopsis>
<command>systemd-escape</command>
<arg choice="opt" rep="repeat">OPTIONS</arg>
<arg choice="opt" rep="repeat">STRING</arg>
<arg choice="plain" rep="repeat">STRING</arg>
</cmdsynopsis>
<cmdsynopsis>
<command>systemd-escape</command>
<arg choice="opt" rep="repeat">OPTIONS</arg>
<arg choice="plain"><option>--stdin</option></arg>
</cmdsynopsis>
</refsynopsisdiv>
+12 -30
View File
@@ -2,22 +2,22 @@
#include <sys/socket.h> /* IWYU pragma: keep */
#include "sd-json.h"
#include "sd-messages.h"
#include "alloc-util.h"
#include "ansi-color.h"
#include "battery-util.h"
#include "build.h"
#include "fd-util.h"
#include "format-table.h"
#include "glyph-util.h"
#include "log.h"
#include "main-func.h"
#include "options.h"
#include "plymouth-util.h"
#include "pretty-print.h"
#include "proc-cmdline.h"
#include "terminal-util.h"
#include "time-util.h"
#include "verbs.h"
#define BATTERY_LOW_MESSAGE \
"Battery level critically low. Please connect your charger or the system will power off in 10 seconds."
@@ -26,32 +26,11 @@
static bool arg_doit = true;
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-battery-check", "8", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s\n\n"
"%sCheck battery level to see whether there's enough charge.%s\n\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
COMMAND(
"systemd-battery-check\0",
"Check battery level to see whether there's enough charge.",
.man_pages = "systemd-battery-check.8\0",
);
static int plymouth_send_message(const char *mode, const char *message) {
_cleanup_free_ char *plymouth_message = NULL;
@@ -87,10 +66,13 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-battery-check");
OPTION_COMMON_VERSION:
return version();
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
if (option_parser_get_n_args(&opts) != 0)
+15 -30
View File
@@ -3,6 +3,8 @@
#include <stdio.h>
#include <sys/stat.h>
#include "sd-json.h"
#include "alloc-util.h"
#include "binfmt-util.h"
#include "build.h"
@@ -11,20 +13,27 @@
#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "format-table.h"
#include "log.h"
#include "main-func.h"
#include "options.h"
#include "pager.h"
#include "path-util.h"
#include "pretty-print.h"
#include "string-util.h"
#include "strv.h"
#include "verbs.h"
static CatFlags arg_cat_flags = CAT_CONFIG_OFF;
static PagerFlags arg_pager_flags = 0;
static bool arg_unregister = false;
COMMAND(
"systemd-binfmt\0",
"Register binary formats with the kernel.",
.argspec = "[CONFIGURATION FILE…]\0",
.man_pages = "systemd-binfmt.service.8\0",
.pager_flags = &arg_pager_flags,
);
static int delete_rule(const char *rulename) {
const char *fn = strjoina("/proc/sys/fs/binfmt_misc/", rulename);
return write_string_file(fn, "-1", WRITE_STRING_FILE_DISABLE_BUFFER);
@@ -107,33 +116,6 @@ static int cat_config(char **files) {
return cat_files(NULL, files, arg_cat_flags);
}
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-binfmt.service", "8", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...] [CONFIGURATION FILE...]\n"
"\n%sRegisters binary formats with the kernel.%s\n"
"\nOptions:\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
static int parse_argv(int argc, char *argv[], char ***ret_args) {
assert(argc >= 0);
@@ -144,7 +126,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
FOREACH_OPTION_OR_RETURN(c, &opts)
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-binfmt");
OPTION_COMMON_VERSION:
return version();
@@ -164,6 +146,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
OPTION_LONG("unregister", NULL, "Unregister all existing entries"):
arg_unregister = true;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
char **args = option_parser_get_args(&opts);
+13 -30
View File
@@ -3,25 +3,24 @@
#include <stdio.h>
#include "sd-bus.h"
#include "sd-json.h"
#include "alloc-util.h"
#include "build.h"
#include "bus-util.h"
#include "cgroup-show.h"
#include "cgroup-util.h"
#include "format-table.h"
#include "log.h"
#include "main-func.h"
#include "options.h"
#include "output-mode.h"
#include "pager.h"
#include "parse-util.h"
#include "path-util.h"
#include "pretty-print.h"
#include "runtime-scope.h"
#include "string-util.h"
#include "strv.h"
#include "unit-name.h"
#include "verbs.h"
static PagerFlags arg_pager_flags = 0;
static OutputFlags arg_output_flags = 0;
@@ -38,32 +37,13 @@ static const char* arg_machine = NULL;
STATIC_DESTRUCTOR_REGISTER(arg_names, strv_freep);
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-cgls", "1", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...] [CGROUP...]\n\n"
"%sRecursively show control group contents.%s\n\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
COMMAND(
"systemd-cgls\0",
"Recursively show control group contents.",
.argspec = "[CGROUP…]\0" "--unit|--user-unit UNIT…\0",
.man_pages = "systemd-cgls.1\0",
.pager_flags = &arg_pager_flags,
);
static int parse_argv(int argc, char *argv[]) {
assert(argc >= 1);
@@ -76,7 +56,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-cgls");
OPTION_COMMON_VERSION:
return version();
@@ -153,6 +133,9 @@ static int parse_argv(int argc, char *argv[]) {
if (strv_extend(&arg_names, opts.arg) < 0) /* push arg */
return log_oom();
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
if (arg_machine && arg_show_unit != SHOW_UNIT_NONE)
+15 -31
View File
@@ -3,28 +3,29 @@
#include <signal.h>
#include <unistd.h>
#include "sd-json.h"
#include "alloc-util.h"
#include "ansi-color.h"
#include "build.h"
#include "cgroup-show.h"
#include "cgroup-util.h"
#include "cpu-set-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "format-table.h"
#include "hashmap.h"
#include "log.h"
#include "main-func.h"
#include "options.h"
#include "parse-argument.h"
#include "parse-util.h"
#include "path-util.h"
#include "pretty-print.h"
#include "process-util.h"
#include "procfs-util.h"
#include "sort-util.h"
#include "string-table.h"
#include "terminal-util.h"
#include "time-util.h"
#include "verbs.h"
#include "virt.h"
typedef struct Group {
@@ -89,6 +90,13 @@ static PidsCount arg_count = COUNT_PIDS;
static Order arg_order = ORDER_CPU;
static CPUType arg_cpu_type = CPU_PERCENTAGE;
COMMAND(
"systemd-cgtop\0",
"Show top control groups by their resource usage.",
.argspec = "[CGROUP]\0",
.man_pages = "systemd-cgtop.1\0",
);
static const char *order_table[_ORDER_MAX] = {
[ORDER_PATH] = "path",
[ORDER_TASKS] = "tasks",
@@ -684,33 +692,6 @@ static void display(Hashmap *a) {
}
}
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-cgtop", "1", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...] [CGROUP]\n\n"
"%sShow top control groups by their resource usage.%s\n\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
static int parse_argv(int argc, char *argv[]) {
assert(argc >= 1);
assert(argv);
@@ -722,7 +703,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-cgtop");
OPTION_COMMON_VERSION:
return version();
@@ -822,6 +803,9 @@ static int parse_argv(int argc, char *argv[]) {
OPTION_COMMON_MACHINE:
arg_machine = opts.arg;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
size_t n_args = option_parser_get_n_args(&opts);
+40 -54
View File
@@ -2,55 +2,55 @@
#include <unistd.h>
#include "sd-json.h"
#include "alloc-util.h"
#include "ansi-color.h"
#include "build.h"
#include "chase.h"
#include "dirent-util.h"
#include "errno-util.h"
#include "extract-word.h"
#include "fd-util.h"
#include "format-table.h"
#include "fs-util.h"
#include "glyph-util.h"
#include "hashmap.h"
#include "log.h"
#include "main-func.h"
#include "nulstr-util.h"
#include "options.h"
#include "pager.h"
#include "parse-argument.h"
#include "path-util.h"
#include "pidref.h"
#include "pretty-print.h"
#include "process-util.h"
#include "stat-util.h"
#include "string-util.h"
#include "strv.h"
#include "verbs.h"
static const char prefixes[] =
"/etc\0"
"/run\0"
"/usr/local/lib\0"
"/usr/local/share\0"
"/usr/lib\0"
#define PREFIXES \
"/etc\0" \
"/run\0" \
"/usr/local/lib\0" \
"/usr/local/share\0" \
"/usr/lib\0" \
"/usr/share\0"
;
static const char suffixes[] =
"sysctl.d\0"
"tmpfiles.d\0"
"modules-load.d\0"
"binfmt.d\0"
"systemd/system\0"
#define SUFFIXES \
"sysctl.d\0" \
"tmpfiles.d\0" \
"modules-load.d\0" \
"binfmt.d\0" \
"systemd/system\0" \
"systemd/user\0" \
"systemd/system-preset\0" \
"systemd/user-preset\0" \
"udev/rules.d\0" \
"modprobe.d\0"
#define HAVE_DROPINS \
"systemd/system\0" \
"systemd/user\0"
"systemd/system-preset\0"
"systemd/user-preset\0"
"udev/rules.d\0"
"modprobe.d\0";
static const char have_dropins[] =
"systemd/system\0"
"systemd/user\0";
static PagerFlags arg_pager_flags = 0;
static int arg_diff = -1;
@@ -67,6 +67,14 @@ static enum {
(SHOW_MASKED | SHOW_EQUIVALENT | SHOW_REDIRECTED | SHOW_OVERRIDDEN | SHOW_EXTENDED)
} arg_flags = 0;
COMMAND(
"systemd-delta\0",
"Find overridden configuration files.",
.argspec = "[SUFFIX…]\0",
.man_pages = "systemd-delta.1\0",
.pager_flags = &arg_pager_flags,
);
static int equivalent(const char *a, const char *b) {
_cleanup_free_ char *x = NULL, *y = NULL;
int r;
@@ -377,10 +385,10 @@ static int process_suffix(const char *suffix, const char *onlyprefix) {
assert(!startswith(suffix, "/"));
assert(!strstr(suffix, "//"));
bool dropins = nulstr_contains(have_dropins, suffix);
bool dropins = nulstr_contains(HAVE_DROPINS, suffix);
_cleanup_ordered_hashmap_free_ OrderedHashmap *top = NULL, *bottom = NULL, *drops = NULL;
NULSTR_FOREACH(p, prefixes) {
NULSTR_FOREACH(p, PREFIXES) {
_cleanup_free_ char *t = NULL;
t = path_join(p, suffix);
@@ -423,7 +431,7 @@ static int process_suffix(const char *suffix, const char *onlyprefix) {
static int process_suffixes(const char *onlyprefix) {
int n_found = 0, r;
NULSTR_FOREACH(n, suffixes) {
NULSTR_FOREACH(n, SUFFIXES) {
r = process_suffix(n, onlyprefix);
if (r < 0)
return r;
@@ -441,7 +449,7 @@ static int process_suffix_chop(const char *arg) {
return process_suffix(arg, NULL);
/* Strip prefix from the suffix */
NULSTR_FOREACH(p, prefixes) {
NULSTR_FOREACH(p, PREFIXES) {
const char *suffix;
suffix = startswith(arg, p);
@@ -458,31 +466,6 @@ static int process_suffix_chop(const char *arg) {
"Invalid suffix specification %s.", arg);
}
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-delta", "1", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...] [SUFFIX...]\n\n"
"Find overridden configuration files.\n\n",
program_invocation_short_name);
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
static int parse_flags(const char *flag_str, int flags) {
for (;;) {
_cleanup_free_ char *word = NULL;
@@ -524,7 +507,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-delta");
OPTION_COMMON_VERSION:
return version();
@@ -548,6 +531,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
return r;
arg_diff = r;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
*ret_args = option_parser_get_args(&opts);
+13 -32
View File
@@ -1,18 +1,17 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
#include "ansi-color.h"
#include "sd-json.h"
#include "build.h"
#include "confidential-virt.h"
#include "format-table.h"
#include "log.h"
#include "main-func.h"
#include "options.h"
#include "pretty-print.h"
#include "string-table.h"
#include "verbs.h"
#include "virt.h"
static bool arg_quiet = false;
static enum {
ANY_VIRTUALIZATION,
ONLY_VM,
@@ -22,32 +21,11 @@ static enum {
ONLY_CVM,
} arg_mode = ANY_VIRTUALIZATION;
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-detect-virt", "1", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...]\n"
"\n%sDetect execution in a virtualized environment.%s\n"
"\nOptions:\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
COMMAND(
"systemd-detect-virt\0",
"Detect execution in a virtualized environment.",
.man_pages = "systemd-detect-virt.1\0",
);
static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
@@ -58,7 +36,7 @@ static int parse_argv(int argc, char *argv[]) {
FOREACH_OPTION_OR_RETURN(c, &opts)
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-detect-virt");
OPTION_COMMON_VERSION:
return version();
@@ -92,6 +70,9 @@ static int parse_argv(int argc, char *argv[]) {
OPTION_LONG("list-cvm", NULL, "List all known and detectable types of confidential virtualization"):
return DUMP_STRING_TABLE(confidential_virtualization, ConfidentialVirtualization, _CONFIDENTIAL_VIRTUALIZATION_MAX);
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
if (option_parser_get_n_args(&opts) > 0)
+13 -30
View File
@@ -2,19 +2,19 @@
#include <stdio.h>
#include "sd-json.h"
#include "alloc-util.h"
#include "build.h"
#include "fileio.h"
#include "format-table.h"
#include "log.h"
#include "main-func.h"
#include "options.h"
#include "path-util.h"
#include "pretty-print.h"
#include "string-util.h"
#include "strv.h"
#include "unit-def.h"
#include "unit-name.h"
#include "verbs.h"
static enum {
ACTION_ESCAPE,
@@ -27,32 +27,12 @@ static bool arg_path = false;
static bool arg_instance = false;
static bool arg_stdin = false;
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-escape", "1", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...] [NAME...]\n\n"
"%sEscape strings for usage in systemd unit names.%s\n\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
COMMAND(
"systemd-escape\0",
"Escape strings for usage in systemd unit names.",
.argspec = "STRING…\0" "--stdin\0",
.man_pages = "systemd-escape.1\0",
);
static int parse_argv(int argc, char *argv[], char ***ret_args) {
assert(argc >= 0);
@@ -64,7 +44,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-escape");
OPTION_COMMON_VERSION:
return version();
@@ -106,6 +86,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
"When escaping/unescaping assume the string is a path"):
arg_path = true;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
if (arg_stdin && option_parser_get_n_args(&opts) > 0)
+12 -24
View File
@@ -5,6 +5,7 @@
#include "sd-bus.h"
#include "sd-id128.h"
#include "sd-json.h"
#include "sd-varlink.h"
#include "alloc-util.h"
@@ -26,10 +27,8 @@
#include "fd-util.h"
#include "fileio.h"
#include "firstboot-util.h"
#include "format-table.h"
#include "fs-util.h"
#include "glyph-util.h"
#include "help-util.h"
#include "hostname-setup.h"
#include "hostname-util.h"
#include "image-policy.h"
@@ -43,7 +42,6 @@
#include "main-func.h"
#include "memory-util.h"
#include "mount-util.h"
#include "options.h"
#include "os-util.h"
#include "parse-argument.h"
#include "password-quality-util.h"
@@ -60,6 +58,7 @@
#include "tmpfile-util.h"
#include "user-util.h"
#include "vconsole-util.h"
#include "verbs.h"
static char *arg_root = NULL;
static char *arg_image = NULL;
@@ -110,6 +109,12 @@ STATIC_DESTRUCTOR_REGISTER(arg_kernel_cmdline, freep);
STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep);
STATIC_DESTRUCTOR_REGISTER(arg_label_context, mac_label_context_freep);
COMMAND(
"systemd-firstboot\0",
"Configure basic settings of the system.",
.man_pages = "systemd-firstboot.1\0",
);
static bool welcome_done = false;
static void print_welcome(int rfd, sd_varlink **mute_console_link) {
@@ -1378,26 +1383,6 @@ static int process_reset(int rfd) {
return 0;
}
static int help(void) {
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
help_cmdline("[OPTIONS...]");
help_abstract("Configures basic settings of the system.");
help_section("Options");
r = table_print_or_warn(options);
if (r < 0)
return r;
help_man_page_reference("systemd-firstboot", "1");
return 0;
}
static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
@@ -1409,7 +1394,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-firstboot");
OPTION_COMMON_VERSION:
return version();
@@ -1628,6 +1613,9 @@ static int parse_argv(int argc, char *argv[]) {
OPTION_LONG("reset", NULL, "Remove existing files"):
arg_reset = true;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
if (arg_delete_root_password && (arg_copy_root_password || arg_root_password || arg_prompt_root_password))
+13 -50
View File
@@ -1,21 +1,25 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
#include "sd-json.h"
#include "build.h"
#include "dlopen-note.h"
#include "format-table.h"
#include "hwdb-util.h"
#include "label-util.h"
#include "log.h"
#include "main-func.h"
#include "options.h"
#include "pretty-print.h"
#include "verbs.h"
static const char *arg_hwdb_bin_dir = NULL;
static const char *arg_root = NULL;
static bool arg_strict = false;
COMMAND(
"systemd-hwdb\0",
"Update or query the hardware database.",
.man_pages = "systemd-hwdb.8\0",
);
VERB(verb_query, "query", "MODALIAS", 2, 2, 0,
"Query database and print result");
static int verb_query(int argc, char *argv[], uintptr_t _data, void *userdata) {
@@ -31,51 +35,7 @@ static int verb_update(int argc, char *argv[], uintptr_t _data, void *userdata)
return hwdb_update(arg_root, arg_hwdb_bin_dir, arg_strict, false);
}
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL;
int r;
r = terminal_urlify_man("systemd-hwdb", "8", &link);
if (r < 0)
return log_oom();
r = verbs_get_help_table(&verbs);
if (r < 0)
return r;
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
(void) table_sync_column_widths(0, verbs, options);
printf("%s [OPTIONS...] COMMAND ...\n\n"
"%sUpdate or query the hardware database.%s\n"
"\n%sCommands:%s\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal(),
ansi_underline(),
ansi_normal());
r = table_print_or_warn(verbs);
if (r < 0)
return r;
printf("\n%sOptions:%s\n",
ansi_underline(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
VERB_COMMON_HELP_HIDDEN(help);
VERB_COMMON_HELP_AUTO_HIDDEN("systemd-hwdb");
static int parse_argv(int argc, char *argv[], char ***ret_args) {
assert(argc >= 0);
@@ -88,7 +48,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-hwdb");
OPTION_COMMON_VERSION:
return version();
@@ -106,6 +66,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
"Generate in " UDEVLIBEXECDIR " instead of /etc/udev"):
arg_hwdb_bin_dir = UDEVLIBEXECDIR;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
*ret_args = option_parser_get_args(&opts);
+12 -22
View File
@@ -4,6 +4,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include "sd-json.h"
#include "sd-varlink.h"
#include "alloc-util.h"
@@ -17,7 +18,6 @@
#include "format-table.h"
#include "format-util.h"
#include "fs-util.h"
#include "help-util.h"
#include "hexdecoct.h"
#include "imds-tool.h"
#include "imds-tool-metrics.h"
@@ -28,13 +28,13 @@
#include "json-util.h"
#include "log.h"
#include "main-func.h"
#include "options.h"
#include "parse-argument.h"
#include "pcrextend-util.h"
#include "string-util.h"
#include "strv.h"
#include "time-util.h"
#include "tmpfile-util.h"
#include "verbs.h"
static enum {
ACTION_SUMMARY,
@@ -51,25 +51,12 @@ static bool arg_refresh_usec_set = false;
STATIC_DESTRUCTOR_REGISTER(arg_key, freep);
static int help(void) {
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
help_cmdline("[OPTIONS...] [KEY]");
help_abstract("IMDS data acquisition.");
help_section("Options");
r = table_print_or_warn(options);
if (r < 0)
return r;
help_man_page_reference("systemd-imds", "1");
return 0;
}
COMMAND(
"systemd-imds\0",
"IMDS data acquisition.",
.argspec = "[KEY]\0",
.man_pages = "systemd-imds.1\0",
);
static int parse_argv(int argc, char *argv[]) {
int r;
@@ -83,7 +70,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-imds");
OPTION_COMMON_VERSION:
return version();
@@ -139,6 +126,9 @@ static int parse_argv(int argc, char *argv[]) {
" and place them in /run/credstore/"):
arg_action = ACTION_IMPORT;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
char **args = option_parser_get_args(&opts);
+13 -34
View File
@@ -5,60 +5,36 @@
#include <sys/ioctl.h>
#include "sd-journal.h"
#include "sd-json.h"
#include "alloc-util.h"
#include "ansi-color.h"
#include "build.h"
#include "dlopen-note.h"
#include "fd-util.h"
#include "fileio.h"
#include "format-table.h"
#include "io-util.h"
#include "log.h"
#include "logs-show.h"
#include "main-func.h"
#include "options.h"
#include "parse-argument.h"
#include "pretty-print.h"
#include "qrcode-util.h"
#include "signal-util.h"
#include "stdio-util.h"
#include "terminal-util.h"
#include "verbs.h"
static bool arg_continuous = false;
static char *arg_tty = NULL;
STATIC_DESTRUCTOR_REGISTER(arg_tty, freep);
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-bsod", "8", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...]\n\n"
"%sFilter the journal to fetch the first message from the current boot with an\n"
"emergency log level and display it as a string and a QR code.%s\n"
"\n%sOptions:%s\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal(),
ansi_underline(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
COMMAND(
"systemd-bsod\0",
"Filter the journal to fetch the first message from the current boot with an emergency "
"log level and display it as a string and a QR code.",
.man_pages = "systemd-bsod.8\0",
);
static int acquire_first_emergency_log_message(char **ret) {
_cleanup_(sd_journal_closep) sd_journal *j = NULL;
@@ -255,7 +231,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-bsod");
OPTION_COMMON_VERSION:
return version();
@@ -269,6 +245,9 @@ static int parse_argv(int argc, char *argv[]) {
if (r < 0)
return r;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
if (option_parser_get_n_args(&opts) > 0)
+12 -32
View File
@@ -1,26 +1,23 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include "sd-journal.h"
#include "sd-json.h"
#include "alloc-util.h"
#include "build.h"
#include "env-util.h"
#include "fd-util.h"
#include "format-table.h"
#include "format-util.h"
#include "log.h"
#include "main-func.h"
#include "options.h"
#include "parse-argument.h"
#include "pretty-print.h"
#include "string-util.h"
#include "strv.h"
#include "syslog-util.h"
#include "verbs.h"
static const char *arg_identifier = NULL;
static const char *arg_namespace = NULL;
@@ -28,32 +25,12 @@ static int arg_priority = LOG_INFO;
static int arg_stderr_priority = -1;
static bool arg_level_prefix = true;
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-cat", "1", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...] COMMAND ...\n\n"
"%sExecute process with stdout/stderr connected to the journal.%s\n\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
COMMAND(
"systemd-cat\0",
"Execute process with stdout/stderr connected to the journal.",
.argspec = "[COMMAND…]\0",
.man_pages = "systemd-cat.1\0",
);
static int parse_argv(int argc, char *argv[], char ***ret_args) {
assert(argc >= 0);
@@ -66,7 +43,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-cat");
OPTION_COMMON_VERSION:
return version();
@@ -101,6 +78,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
"Connect to specified journal namespace"):
arg_namespace = empty_to_null(opts.arg);
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
*ret_args = option_parser_get_args(&opts);
+16 -30
View File
@@ -6,6 +6,7 @@
#include <unistd.h>
#include "sd-bus.h"
#include "sd-json.h"
#include "alloc-util.h"
#include "build.h"
@@ -17,12 +18,10 @@
#include "format-table.h"
#include "log.h"
#include "main-func.h"
#include "options.h"
#include "pager.h"
#include "parse-argument.h"
#include "pidref.h"
#include "polkit-agent.h"
#include "pretty-print.h"
#include "process-util.h"
#include "runtime-scope.h"
#include "signal-util.h"
@@ -30,6 +29,7 @@
#include "strv.h"
#include "terminal-util.h"
#include "user-util.h"
#include "verbs.h"
static const char *arg_what = NULL;
static const char *arg_who = NULL;
@@ -45,6 +45,16 @@ static enum {
ACTION_LIST
} arg_action = ACTION_INHIBIT;
COMMAND(
"systemd-inhibit\0",
"Execute a process while inhibiting shutdown/sleep/idle.",
.argspec =
"COMMAND…\0"
"--list\0",
.man_pages = "systemd-inhibit.1\0",
.pager_flags = &arg_pager_flags,
);
static int inhibit(sd_bus *bus, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
int r;
@@ -168,33 +178,6 @@ static int print_inhibitors(sd_bus *bus) {
return 0;
}
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-inhibit", "1", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...] COMMAND ...\n\n"
"%sExecute a process while inhibiting shutdown/sleep/idle.%s\n\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
static int parse_argv(int argc, char *argv[], char ***remaining_args) {
assert(argc >= 0);
assert(argv);
@@ -207,7 +190,7 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-inhibit");
OPTION_COMMON_VERSION:
return version();
@@ -255,6 +238,9 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
OPTION_LONG("list", NULL, "List active inhibitors"):
arg_action = ACTION_LIST;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
char **args = option_parser_get_args(&opts);
+11 -31
View File
@@ -4,57 +4,34 @@
#include "sd-bus.h"
#include "sd-event.h"
#include "sd-json.h"
#include "sd-varlink.h"
#include "alloc-util.h"
#include "ansi-color.h"
#include "build.h"
#include "bus-error.h"
#include "bus-locator.h"
#include "bus-util.h"
#include "daemon-util.h"
#include "errno-util.h"
#include "format-table.h"
#include "log.h"
#include "main-func.h"
#include "options.h"
#include "parse-argument.h"
#include "pretty-print.h"
#include "printk-util.h"
#include "varlink-io.systemd.MuteConsole.h"
#include "varlink-util.h"
#include "verbs.h"
#include "virt.h"
static bool arg_mute_pid1 = true;
static bool arg_mute_kernel = true;
static bool arg_varlink = false;
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-mute-console", "1", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...]\n\n"
"%sMute status output to the console.%s\n\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
COMMAND(
"systemd-mute-console\0",
"Mute status output to the console.",
.man_pages = "systemd-mute-console.1\0",
);
static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
@@ -67,7 +44,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-mute-console");
OPTION_COMMON_VERSION:
return version();
@@ -83,6 +60,9 @@ static int parse_argv(int argc, char *argv[]) {
if (r < 0)
return r;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
r = sd_varlink_invocation(SD_VARLINK_ALLOW_ACCEPT);
+11 -28
View File
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-event.h"
#include "sd-json.h"
#include "alloc-util.h"
#include "build.h"
@@ -9,43 +10,22 @@
#include "cgroup-util.h"
#include "daemon-util.h"
#include "fileio.h"
#include "format-table.h"
#include "log.h"
#include "main-func.h"
#include "oomd-conf.h"
#include "oomd-manager.h"
#include "oomd-manager-bus.h"
#include "options.h"
#include "parse-util.h"
#include "pretty-print.h"
#include "psi-util.h"
#include "verbs.h"
static bool arg_dry_run = false;
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-oomd", "8", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...]\n\n"
"Run the userspace out-of-memory (OOM) killer.\n\n",
program_invocation_short_name);
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
COMMAND(
"systemd-oomd\0",
"Run the userspace out-of-memory (OOM) killer.",
.man_pages = "systemd-oomd.8\0",
);
static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
@@ -57,7 +37,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-oomd");
OPTION_COMMON_VERSION:
return version();
@@ -74,6 +54,9 @@ static int parse_argv(int argc, char *argv[]) {
opts.arg,
BUS_IMPLEMENTATIONS(&manager_object,
&log_control_object));
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
if (option_parser_get_n_args(&opts) > 0)
+15 -31
View File
@@ -2,24 +2,32 @@
#include <stdio.h>
#include "sd-json.h"
#include "sd-path.h"
#include "alloc-util.h"
#include "ansi-color.h"
#include "build.h"
#include "errno-util.h"
#include "format-table.h"
#include "log.h"
#include "main-func.h"
#include "options.h"
#include "pager.h"
#include "pretty-print.h"
#include "sort-util.h"
#include "string-util.h"
#include "strv.h"
#include "verbs.h"
static const char *arg_suffix = NULL;
static PagerFlags arg_pager_flags = 0;
COMMAND(
"systemd-path\0",
"Show system and user paths.",
.argspec = "[NAME…]\0",
.man_pages = "systemd-path.1\0",
.pager_flags = &arg_pager_flags,
);
static const char* const path_table[_SD_PATH_MAX] = {
[SD_PATH_TEMPORARY] = "temporary",
[SD_PATH_TEMPORARY_LARGE] = "temporary-large",
@@ -173,33 +181,6 @@ static int print_path(const char *n) {
"Path %s not known.", n);
}
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-path", "1", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...] [NAME...]\n\n"
"%sShow system and user paths.%s\n\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
static int parse_argv(int argc, char *argv[], char ***ret_args) {
assert(argc >= 0);
assert(argv);
@@ -210,7 +191,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-path");
OPTION_COMMON_VERSION:
return version();
@@ -222,6 +203,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
OPTION_COMMON_NO_PAGER:
arg_pager_flags |= PAGER_DISABLE;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
*ret_args = option_parser_get_args(&opts);
+13 -33
View File
@@ -2,22 +2,22 @@
#include <unistd.h>
#include "sd-json.h"
#include "alloc-util.h"
#include "build.h"
#include "event-util.h"
#include "fd-util.h"
#include "format-table.h"
#include "log.h"
#include "main-func.h"
#include "options.h"
#include "parse-argument.h"
#include "pidref.h"
#include "pretty-print.h"
#include "process-util.h"
#include "ptyfwd.h"
#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"
#include "verbs.h"
static bool arg_quiet = false;
static bool arg_read_only = false;
@@ -27,35 +27,12 @@ static char *arg_title = NULL;
STATIC_DESTRUCTOR_REGISTER(arg_background, freep);
STATIC_DESTRUCTOR_REGISTER(arg_title, freep);
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-pty-forward", "1", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...] COMMAND ...\n"
"\n%sRun command with a custom terminal background color or title.%s\n"
"\n%sOptions:%s\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal(),
ansi_underline(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
COMMAND(
"systemd-pty-forward\0",
"Run command with a custom terminal background color or title.",
.argspec = "COMMAND…\0",
.man_pages = "systemd-pty-forward.1\0",
);
static int parse_argv(int argc, char *argv[], char ***remaining_args) {
assert(argc >= 0);
@@ -69,7 +46,7 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-pty-forward");
OPTION_COMMON_VERSION:
return version();
@@ -93,6 +70,9 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
if (r < 0)
return r;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
if (option_parser_get_n_args(&opts) == 0)
+14 -35
View File
@@ -5,6 +5,7 @@
#include <unistd.h>
#include "sd-daemon.h"
#include "sd-json.h"
#include "alloc-util.h"
#include "build.h"
@@ -14,19 +15,17 @@
#include "errno-util.h"
#include "escape.h"
#include "fd-util.h"
#include "format-table.h"
#include "format-util.h"
#include "log.h"
#include "main-func.h"
#include "options.h"
#include "pidfd-util.h"
#include "pidref.h"
#include "pretty-print.h"
#include "process-util.h"
#include "socket-netlink.h"
#include "socket-util.h"
#include "string-util.h"
#include "strv.h"
#include "verbs.h"
static char **arg_listen = NULL;
static bool arg_accept = false;
@@ -36,6 +35,14 @@ static char **arg_fdnames = NULL;
static bool arg_inetd = false;
static bool arg_now = false;
COMMAND(
"systemd-socket-activate\0",
"Listen on sockets and launch child on connection.",
.argspec = "COMMAND…\0",
.footer = "Note: file descriptors from sd_listen_fds() will be passed through.",
.man_pages = "systemd-socket-activate.1\0",
);
static int add_epoll(int epoll_fd, int fd) {
struct epoll_event ev = {
.events = EPOLLIN,
@@ -320,37 +327,6 @@ static int install_chld_handler(void) {
return 0;
}
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-socket-activate", "1", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...] COMMAND ...\n"
"\n%sListen on sockets and launch child on connection.%s\n"
"\n%sOptions:%s\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal(),
ansi_underline(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nNote: file descriptors from sd_listen_fds() will be passed through.\n"
"\nSee the %s for details.\n", link);
return 0;
}
static int parse_argv(int argc, char *argv[], char ***remaining_args) {
assert(argc >= 0);
assert(argv);
@@ -363,7 +339,7 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-socket-activate");
OPTION_COMMON_VERSION:
return version();
@@ -441,6 +417,9 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
"Start instantly instead of waiting for connection"):
arg_now = true;
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
*remaining_args = option_parser_get_args(&opts);
@@ -12,6 +12,8 @@
#include <sys/wait.h>
#include <unistd.h>
#include "sd-json.h"
#include "alloc-util.h"
#include "ask-password-api.h"
#include "build.h"
@@ -24,16 +26,13 @@
#include "exit-status.h"
#include "fd-util.h"
#include "fileio.h"
#include "format-table.h"
#include "format-util.h"
#include "inotify-util.h"
#include "io-util.h"
#include "main-func.h"
#include "mkdir.h"
#include "options.h"
#include "path-util.h"
#include "pidref.h"
#include "pretty-print.h"
#include "process-util.h"
#include "set.h"
#include "signal-util.h"
@@ -43,6 +42,7 @@
#include "strv.h"
#include "terminal-util.h"
#include "time-util.h"
#include "verbs.h"
#include "wall.h"
static enum {
@@ -58,6 +58,12 @@ static char *arg_device = NULL;
STATIC_DESTRUCTOR_REGISTER(arg_device, freep);
COMMAND(
"systemd-tty-ask-password-agent\0",
"Process system password requests.",
.man_pages = "systemd-tty-ask-password-agent.1\0",
);
static int send_passwords(const char *socket_name, char **passwords) {
int r;
@@ -442,33 +448,6 @@ static int process_and_watch_password_files(bool watch) {
return 0;
}
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-tty-ask-password-agent", "1", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...]\n"
"\n%sProcess system password requests.%s\n\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
@@ -480,7 +459,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-tty-ask-password-agent");
OPTION_COMMON_VERSION:
return version();
@@ -519,6 +498,9 @@ static int parse_argv(int argc, char *argv[]) {
return r;
}
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
if (option_parser_get_n_args(&opts) > 0)
+45 -11
View File
@@ -3,9 +3,46 @@
set -eux
set -o pipefail
# Just a smoke test for the introspection code
for i in systemd-ac-power systemd-analyze systemd-ask-password systemd-dissect \
systemd-id128 systemd-notify homectl resolvectl timedatectl varlinkctl; do
# Some commands are in $PATH, others are in our private directory.
# Check the other location too.
PATH=$PATH:/usr/lib/systemd
# A smoke test for the introspection code
INTROSPECTABLE=(
homectl
resolvectl
systemd-ac-power
systemd-analyze
systemd-ask-password
systemd-backlight
systemd-battery-check
systemd-binfmt
systemd-bsod
systemd-cat
systemd-cgls
systemd-cgtop
systemd-delta
systemd-detect-virt
systemd-dissect
systemd-escape
systemd-firstboot
systemd-hwdb
systemd-id128
systemd-imds
systemd-inhibit
systemd-mute-console
systemd-notify
systemd-oomd
systemd-path
systemd-pty-forward
systemd-socket-activate
systemd-tty-ask-password-agent
systemd-veritysetup
timedatectl
varlinkctl
)
for i in "${INTROSPECTABLE[@]}"; do
command -v "$i" >/dev/null || continue
$i --introspect-cli | jq -e \
@@ -17,14 +54,11 @@ for i in systemd-ac-power systemd-analyze systemd-ask-password systemd-dissect \
$i --intro | grep -e --help
done
# Those are not in $PATH and do not do regular option parsing, so the option must
# be given verbatim
for i in /usr/lib/systemd/systemd-backlight /usr/lib/systemd/systemd-veritysetup; do
[[ -x "$i" ]] || continue
$i --introspect-cli | jq -e \
'.mediaType == "application/vnd.io.systemd.cli-introspection-0"'
done
# systemd-hwdb defines verbs, check that they are described
if command -v systemd-hwdb >/dev/null; then
systemd-hwdb --introspect-cli | jq -e \
'.commands[0].verbs | map(.names[0]) | contains(["query", "update"])'
fi
# systemd-id128 defines verbs, check that they are described
systemd-id128 --introspect-cli | jq -e \