Another batch of conversions to COMMAND and additions of --introspect-cli (#43418)
This commit is contained in:
+28
-46
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sd-json.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "build.h"
|
||||
#include "devnum-util.h"
|
||||
@@ -9,14 +11,11 @@
|
||||
#include "efivars.h"
|
||||
#include "fd-util.h"
|
||||
#include "find-esp.h"
|
||||
#include "format-table.h"
|
||||
#include "fs-util.h"
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "options.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "pretty-print.h"
|
||||
#include "stdio-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
@@ -28,52 +27,32 @@ static char **arg_path = NULL;
|
||||
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_path, strv_freep);
|
||||
|
||||
COMMAND(
|
||||
"systemd-bless-boot\0",
|
||||
"Mark the boot process as good or bad.",
|
||||
.man_pages = "systemd-bless-boot.service.8\0",
|
||||
);
|
||||
|
||||
typedef enum Status {
|
||||
STATUS_GOOD,
|
||||
STATUS_BAD,
|
||||
STATUS_INDETERMINATE,
|
||||
} Status;
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
_cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL;
|
||||
int r;
|
||||
VERB_COMMON_HELP_AUTO_HIDDEN("systemd-bless-boot");
|
||||
|
||||
r = terminal_urlify_man("systemd-bless-boot.service", "8", &link);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
static int check_support(void) {
|
||||
if (detect_container() > 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"Marking a boot is not supported in containers.");
|
||||
|
||||
r = option_parser_get_help_table(&options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (!is_efi_boot())
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"Marking a boot is only supported on EFI systems.");
|
||||
|
||||
r = verbs_get_help_table(&verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
(void) table_sync_column_widths(0, options, verbs);
|
||||
|
||||
printf("%s [OPTIONS...] COMMAND\n"
|
||||
"\n%sMark the boot process as good or bad.%s\n"
|
||||
"\nCommands:\n",
|
||||
program_invocation_short_name,
|
||||
ansi_highlight(),
|
||||
ansi_normal());
|
||||
r = table_print_or_warn(verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
printf("\nOptions:\n");
|
||||
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);
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
int r;
|
||||
|
||||
@@ -85,7 +64,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-bless-boot");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -95,6 +74,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(SD_JSON_FORMAT_OFF);
|
||||
}
|
||||
|
||||
*ret_args = option_parser_get_args(&opts);
|
||||
@@ -346,6 +328,10 @@ static int verb_status(int argc, char *argv[], uintptr_t _data, void *userdata)
|
||||
uint64_t left, done;
|
||||
int r;
|
||||
|
||||
r = check_support();
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = acquire_boot_count_path(&path, &prefix, &left, &done, &suffix);
|
||||
if (r == -EUNATCH) { /* No boot count in place, then let's consider this a "clean" boot,
|
||||
* since "good", "bad", or "indeterminate" don't apply. */
|
||||
@@ -463,6 +449,10 @@ static int verb_set(int argc, char *argv[], uintptr_t data, void *userdata) {
|
||||
|
||||
assert(IN_SET(status, STATUS_GOOD, STATUS_BAD, STATUS_INDETERMINATE));
|
||||
|
||||
r = check_support();
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = acquire_boot_count_path(&path, &prefix, &left, &done, &suffix);
|
||||
if (r == -EUNATCH) /* acquire_boot_count_path() won't log on its own for this specific error */
|
||||
return log_error_errno(r, "Not booted with boot counting in effect.");
|
||||
@@ -575,14 +565,6 @@ static int run(int argc, char *argv[]) {
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
if (detect_container() > 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"Marking a boot is not supported in containers.");
|
||||
|
||||
if (!is_efi_boot())
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"Marking a boot is only supported on EFI systems.");
|
||||
|
||||
return dispatch_verb(args, NULL);
|
||||
}
|
||||
|
||||
|
||||
+13
-38
@@ -26,12 +26,10 @@
|
||||
#include "fileio.h"
|
||||
#include "format-table.h"
|
||||
#include "glyph-util.h"
|
||||
#include "help-util.h"
|
||||
#include "log.h"
|
||||
#include "logarithm.h"
|
||||
#include "main-func.h"
|
||||
#include "memstream-util.h"
|
||||
#include "options.h"
|
||||
#include "os-util.h"
|
||||
#include "pager.h"
|
||||
#include "parse-argument.h"
|
||||
@@ -77,6 +75,14 @@ static uint64_t arg_limit_signals = 1;
|
||||
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_matches, strv_freep);
|
||||
|
||||
COMMAND(
|
||||
"busctl\0",
|
||||
"Introspect the D-Bus IPC bus.",
|
||||
.man_pages = "busctl.1\0",
|
||||
.pager_flags = &arg_pager_flags,
|
||||
.flags = COMMAND_HELP_SEPARATE, /* the verb table is very wide */
|
||||
);
|
||||
|
||||
#define NAME_IS_ACQUIRED INT_TO_PTR(1)
|
||||
#define NAME_IS_ACTIVATABLE INT_TO_PTR(2)
|
||||
|
||||
@@ -2073,41 +2079,7 @@ static int verb_set_property(int argc, char *argv[], uintptr_t _data, void *user
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL;
|
||||
int r;
|
||||
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = verbs_get_help_table(&verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = option_parser_get_help_table(&options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* Note: column widths are not synced, because the verbs table is very wide. */
|
||||
|
||||
help_cmdline("[OPTIONS…] COMMAND …");
|
||||
help_abstract("Introspect the D-Bus IPC bus.");
|
||||
|
||||
help_section("Commands");
|
||||
r = table_print_or_warn(verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_section("Options");
|
||||
r = table_print_or_warn(options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_man_page_reference("busctl", "1");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VERB_COMMON_HELP(help);
|
||||
VERB_COMMON_HELP_AUTO("busctl");
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
assert(argc >= 0);
|
||||
@@ -2121,7 +2093,7 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("busctl");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -2305,6 +2277,9 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
|
||||
arg_limit_signals = arg_limit_messages;
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(arg_json_format_flags);
|
||||
}
|
||||
|
||||
if (arg_full < 0)
|
||||
|
||||
+12
-35
@@ -30,7 +30,6 @@
|
||||
#include "format-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "glob-util.h"
|
||||
#include "help-util.h"
|
||||
#include "image-policy.h"
|
||||
#include "io-util.h"
|
||||
#include "journal-internal.h"
|
||||
@@ -41,7 +40,6 @@
|
||||
#include "loop-util.h"
|
||||
#include "main-func.h"
|
||||
#include "mount-util.h"
|
||||
#include "options.h"
|
||||
#include "pager.h"
|
||||
#include "parse-argument.h"
|
||||
#include "parse-util.h"
|
||||
@@ -83,6 +81,13 @@ STATIC_DESTRUCTOR_REGISTER(arg_image, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_file, strv_freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep);
|
||||
|
||||
COMMAND(
|
||||
"coredumpctl\0",
|
||||
"List or retrieve coredumps from the journal.",
|
||||
.man_pages = "coredumpctl.1\0",
|
||||
.pager_flags = &arg_pager_flags,
|
||||
);
|
||||
|
||||
static int add_match(sd_journal *j, const char *match) {
|
||||
_cleanup_free_ char *p = NULL;
|
||||
const char *field;
|
||||
@@ -178,38 +183,7 @@ static int acquire_journal(sd_journal **ret, char **matches) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_(table_unrefp) Table *verbs = NULL, *options = NULL;
|
||||
int r;
|
||||
|
||||
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);
|
||||
|
||||
help_cmdline("[OPTIONS…] COMMAND …");
|
||||
help_abstract("List or retrieve coredumps from the journal.");
|
||||
|
||||
help_section("Commands");
|
||||
r = table_print_or_warn(verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_section("Options");
|
||||
r = table_print_or_warn(options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_man_page_reference("coredumpctl", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
VERB_COMMON_HELP_HIDDEN(help);
|
||||
VERB_COMMON_HELP_AUTO_HIDDEN("coredumpctl");
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
int r;
|
||||
@@ -224,7 +198,7 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("coredumpctl");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -339,6 +313,9 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
OPTION_LONG("all", NULL, "Look at all journal files instead of local ones"):
|
||||
arg_all = true;
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(arg_json_format_flags);
|
||||
}
|
||||
|
||||
if (arg_since != USEC_INFINITY && arg_until != USEC_INFINITY &&
|
||||
|
||||
+13
-48
@@ -7,6 +7,7 @@
|
||||
#include "sd-varlink.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "ansi-color.h"
|
||||
#include "build.h"
|
||||
#include "bus-polkit.h"
|
||||
#include "bus-util.h"
|
||||
@@ -24,12 +25,10 @@
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "memory-util.h"
|
||||
#include "options.h"
|
||||
#include "pager.h"
|
||||
#include "parse-argument.h"
|
||||
#include "parse-util.h"
|
||||
#include "polkit-agent.h"
|
||||
#include "pretty-print.h"
|
||||
#include "stat-util.h"
|
||||
#include "string-table.h"
|
||||
#include "string-util.h"
|
||||
@@ -79,6 +78,13 @@ static bool arg_ask_password = true;
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_tpm2_public_key, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_tpm2_signature, freep);
|
||||
|
||||
COMMAND(
|
||||
"systemd-creds\0",
|
||||
"Display and process credentials.",
|
||||
.man_pages = "systemd-creds.1\0",
|
||||
.pager_flags = &arg_pager_flags,
|
||||
);
|
||||
|
||||
static const char* transcode_mode_table[_TRANSCODE_MAX] = {
|
||||
[TRANSCODE_OFF] = "off",
|
||||
[TRANSCODE_BASE64] = "base64",
|
||||
@@ -773,51 +779,7 @@ static int verb_has_tpm2(int argc, char *argv[], uintptr_t _data, void *userdata
|
||||
return verb_has_tpm2_generic(arg_quiet);
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
_cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL;
|
||||
int r;
|
||||
|
||||
r = terminal_urlify_man("systemd-creds", "1", &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"
|
||||
"%sDisplay and Process Credentials.%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(help);
|
||||
VERB_COMMON_HELP_AUTO("systemd-creds");
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
assert(argc >= 0);
|
||||
@@ -830,7 +792,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("systemd-creds");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -1022,6 +984,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
OPTION('q', "quiet", NULL, "Suppress informational messages"):
|
||||
arg_quiet = true;
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(arg_json_format_flags);
|
||||
}
|
||||
|
||||
SET_FLAG(arg_credential_flags, CREDENTIAL_IPC_ALLOW_INTERACTIVE, arg_ask_password);
|
||||
|
||||
+11
-49
@@ -25,7 +25,6 @@
|
||||
#include "escape.h"
|
||||
#include "extract-word.h"
|
||||
#include "fileio.h"
|
||||
#include "format-table.h"
|
||||
#include "fs-util.h"
|
||||
#include "hexdecoct.h"
|
||||
#include "json-util.h"
|
||||
@@ -35,12 +34,10 @@
|
||||
#include "main-func.h"
|
||||
#include "memory-util.h"
|
||||
#include "nulstr-util.h"
|
||||
#include "options.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "pcrextend-util.h"
|
||||
#include "pkcs11-util.h"
|
||||
#include "pretty-print.h"
|
||||
#include "process-util.h"
|
||||
#include "random-util.h"
|
||||
#include "string-table.h"
|
||||
@@ -145,6 +142,12 @@ STATIC_DESTRUCTOR_REGISTER(arg_link_key_type, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_link_key_description, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_fixate_volume_key, freep);
|
||||
|
||||
COMMAND(
|
||||
"systemd-cryptsetup\0",
|
||||
"Attach or detach an encrypted block device.",
|
||||
.man_pages = "systemd-cryptsetup.8\0",
|
||||
);
|
||||
|
||||
static const char* const passphrase_type_table[_PASSPHRASE_TYPE_MAX] = {
|
||||
[PASSPHRASE_REGULAR] = "passphrase",
|
||||
[PASSPHRASE_RECOVERY_KEY] = "recovery key",
|
||||
@@ -2376,51 +2379,7 @@ static int attach_luks_or_plain_or_bitlk(
|
||||
return attach_luks_or_plain_or_bitlk_by_passphrase(cd, name, passwords, flags, pass_volume_key);
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
_cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL;
|
||||
int r;
|
||||
|
||||
r = terminal_urlify_man("systemd-cryptsetup", "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"
|
||||
"%sAttach or detach an encrypted block device.%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-cryptsetup");
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
assert(argc >= 0);
|
||||
@@ -2433,10 +2392,13 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("systemd-cryptsetup");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(SD_JSON_FORMAT_OFF);
|
||||
}
|
||||
|
||||
*ret_args = option_parser_get_args(&opts);
|
||||
|
||||
@@ -4,19 +4,15 @@
|
||||
#include "sd-varlink.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "ansi-color.h"
|
||||
#include "build.h"
|
||||
#include "device-util.h"
|
||||
#include "efivars.h"
|
||||
#include "errno-util.h"
|
||||
#include "factory-reset.h"
|
||||
#include "format-table.h"
|
||||
#include "fs-util.h"
|
||||
#include "json-util.h"
|
||||
#include "main-func.h"
|
||||
#include "options.h"
|
||||
#include "os-util.h"
|
||||
#include "pretty-print.h"
|
||||
#include "udev-util.h"
|
||||
#include "varlink-io.systemd.FactoryReset.h"
|
||||
#include "varlink-util.h"
|
||||
@@ -26,43 +22,11 @@ static bool arg_retrigger = false;
|
||||
static bool arg_quiet = false;
|
||||
static bool arg_varlink = 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-factory-reset", "8", &link);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
r = option_parser_get_help_table(&options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = verbs_get_help_table(&verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
(void) table_sync_column_widths(0, options, verbs);
|
||||
|
||||
printf("%s [OPTIONS...] COMMAND\n"
|
||||
"\n%sQuery, request, cancel factory reset operation.%s\n"
|
||||
"\nCommands:\n",
|
||||
program_invocation_short_name,
|
||||
ansi_highlight(),
|
||||
ansi_normal());
|
||||
r = table_print_or_warn(verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
printf("\nOptions:\n");
|
||||
r = table_print_or_warn(options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
printf("\nSee the %s for details.\n", link);
|
||||
return 0;
|
||||
}
|
||||
COMMAND(
|
||||
"systemd-factory-reset\0",
|
||||
"Query, request, or cancel a factory reset operation.",
|
||||
.man_pages = "systemd-factory-reset.8\0",
|
||||
);
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
int r;
|
||||
@@ -75,7 +39,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-factory-reset");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -87,6 +51,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
OPTION('q', "quiet", NULL, "Suppress output"):
|
||||
arg_quiet = true;
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(SD_JSON_FORMAT_OFF);
|
||||
}
|
||||
|
||||
r = sd_varlink_invocation(SD_VARLINK_ALLOW_ACCEPT);
|
||||
|
||||
+11
-35
@@ -19,12 +19,10 @@
|
||||
#include "bus-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "format-table.h"
|
||||
#include "help-util.h"
|
||||
#include "hostname-setup.h"
|
||||
#include "hostname-util.h"
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "options.h"
|
||||
#include "os-util.h"
|
||||
#include "parse-argument.h"
|
||||
#include "polkit-agent.h"
|
||||
@@ -42,6 +40,12 @@ static bool arg_pretty = false;
|
||||
static bool arg_static = false;
|
||||
static sd_json_format_flags_t arg_json_format_flags = SD_JSON_FORMAT_OFF;
|
||||
|
||||
COMMAND(
|
||||
"hostnamectl\0",
|
||||
"Query or change system hostname.",
|
||||
.man_pages = "hostnamectl.1\0",
|
||||
);
|
||||
|
||||
typedef struct StatusInfo {
|
||||
const char *hostname;
|
||||
const char *static_hostname;
|
||||
@@ -849,38 +853,7 @@ static int verb_get_or_set_tags(int argc, char *argv[], uintptr_t _data, void *u
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL;
|
||||
int r;
|
||||
|
||||
r = option_parser_get_help_table(&options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = verbs_get_help_table(&verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
(void) table_sync_column_widths(0, options, verbs);
|
||||
|
||||
help_cmdline("[OPTIONS...] COMMAND ...");
|
||||
help_abstract("Query or change system hostname.");
|
||||
|
||||
help_section("Commands");
|
||||
r = table_print_or_warn(verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_section("Options");
|
||||
r = table_print_or_warn(options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_man_page_reference("hostnamectl", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
VERB_COMMON_HELP_HIDDEN(help);
|
||||
VERB_COMMON_HELP_AUTO_HIDDEN("hostnamectl");
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
int r;
|
||||
@@ -893,7 +866,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("hostnamectl");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -934,6 +907,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
OPTION_COMMON_LOWERCASE_J:
|
||||
arg_json_format_flags = SD_JSON_FORMAT_PRETTY_AUTO|SD_JSON_FORMAT_COLOR_AUTO;
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(arg_json_format_flags);
|
||||
}
|
||||
|
||||
*ret_args = option_parser_get_args(&opts);
|
||||
|
||||
+13
-49
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "sd-bus.h"
|
||||
#include "sd-event.h"
|
||||
#include "sd-json.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "build.h"
|
||||
@@ -19,7 +20,6 @@
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "oci-util.h"
|
||||
#include "options.h"
|
||||
#include "os-util.h"
|
||||
#include "pager.h"
|
||||
#include "parse-argument.h"
|
||||
@@ -48,6 +48,13 @@ static sd_json_format_flags_t arg_json_format_flags = SD_JSON_FORMAT_OFF;
|
||||
static ImageClass arg_image_class = _IMAGE_CLASS_INVALID;
|
||||
static RuntimeScope arg_runtime_scope = RUNTIME_SCOPE_SYSTEM;
|
||||
|
||||
COMMAND(
|
||||
"importctl\0",
|
||||
"Download, import or export disk images.",
|
||||
.man_pages = "importctl.1\0",
|
||||
.pager_flags = &arg_pager_flags,
|
||||
);
|
||||
|
||||
#define PROGRESS_PREFIX "Total:"
|
||||
|
||||
static int settle_image_class(void) {
|
||||
@@ -1059,53 +1066,7 @@ static int verb_list_images(int argc, char *argv[], uintptr_t _data, void *userd
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
_cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL;
|
||||
int r;
|
||||
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = terminal_urlify_man("importctl", "1", &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"
|
||||
"%sDownload, import or export disk images%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(help);
|
||||
VERB_COMMON_HELP_AUTO("importctl");
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
int r;
|
||||
@@ -1119,7 +1080,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("importctl");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -1236,6 +1197,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
arg_import_flags &= ~IMPORT_PULL_KEEP_DOWNLOAD;
|
||||
arg_import_flags_mask |= IMPORT_PULL_KEEP_DOWNLOAD;
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(arg_json_format_flags);
|
||||
}
|
||||
|
||||
*ret_args = option_parser_get_args(&opts);
|
||||
|
||||
+12
-48
@@ -1,5 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "sd-json.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "ask-password-api.h"
|
||||
#include "build.h"
|
||||
@@ -7,13 +9,10 @@
|
||||
#include "dlopen-note.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "format-table.h"
|
||||
#include "fs-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 "tmpfile-util.h"
|
||||
#include "verbs.h"
|
||||
@@ -37,51 +36,13 @@ STATIC_DESTRUCTOR_REGISTER(arg_signature, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_content, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_output, freep);
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
_cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL;
|
||||
int r;
|
||||
COMMAND(
|
||||
"systemd-keyutil\0",
|
||||
"Perform various operations on private keys and certificates.",
|
||||
.man_pages = "systemd-keyutil.1\0",
|
||||
);
|
||||
|
||||
r = terminal_urlify_man("systemd-keyutil", "1", &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"
|
||||
"%sPerform various operations on private keys and certificates.%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-keyutil");
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
assert(argc >= 0);
|
||||
@@ -95,7 +56,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("systemd-keyutil");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -152,6 +113,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(SD_JSON_FORMAT_OFF);
|
||||
}
|
||||
|
||||
if (arg_private_key_source && !arg_certificate)
|
||||
|
||||
+14
-37
@@ -1,9 +1,10 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "sd-bus.h"
|
||||
#include "sd-json.h"
|
||||
|
||||
#include "ansi-color.h"
|
||||
#include "alloc-util.h"
|
||||
#include "ansi-color.h"
|
||||
#include "build.h"
|
||||
#include "bus-error.h"
|
||||
#include "bus-locator.h"
|
||||
@@ -12,12 +13,10 @@
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "format-table.h"
|
||||
#include "help-util.h"
|
||||
#include "kbd-util.h"
|
||||
#include "locale-setup.h"
|
||||
#include "main-func.h"
|
||||
#include "memory-util.h"
|
||||
#include "options.h"
|
||||
#include "pager.h"
|
||||
#include "parse-argument.h"
|
||||
#include "path-util.h"
|
||||
@@ -38,6 +37,13 @@ static const char *arg_host = NULL;
|
||||
static bool arg_convert = true;
|
||||
static bool arg_full = false;
|
||||
|
||||
COMMAND(
|
||||
"localectl\0",
|
||||
"Query or change system locale and keyboard settings.",
|
||||
.man_pages = "localectl.1\0",
|
||||
.pager_flags = &arg_pager_flags,
|
||||
);
|
||||
|
||||
typedef struct StatusInfo {
|
||||
char **locale;
|
||||
const char *vconsole_keymap;
|
||||
@@ -420,39 +426,7 @@ static int verb_list_x11_keymaps(int argc, char *argv[], uintptr_t _data, void *
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL;
|
||||
int r;
|
||||
|
||||
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);
|
||||
|
||||
help_cmdline("[OPTIONS…] COMMAND …");
|
||||
help_abstract("Query or change system locale and keyboard settings.");
|
||||
|
||||
help_section("Commands");
|
||||
r = table_print_or_warn(verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_section("Options");
|
||||
r = table_print_or_warn(options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_man_page_reference("localectl", "1");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VERB_COMMON_HELP_HIDDEN(help);
|
||||
VERB_COMMON_HELP_AUTO_HIDDEN("localectl");
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
assert(argc >= 0);
|
||||
@@ -466,7 +440,7 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("localectl");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -497,6 +471,9 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
OPTION_LONG("no-convert", NULL, "Don't convert keyboard mappings"):
|
||||
arg_convert = false;
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(SD_JSON_FORMAT_OFF);
|
||||
}
|
||||
|
||||
*remaining_args = option_parser_get_args(&opts);
|
||||
|
||||
+1
-1
@@ -240,7 +240,7 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(SD_JSON_FORMAT_OFF);
|
||||
return introspect_cli(arg_json_format_flags);
|
||||
}
|
||||
|
||||
char **args = option_parser_get_args(&opts);
|
||||
|
||||
+12
-36
@@ -5,8 +5,6 @@
|
||||
#include "alloc-util.h"
|
||||
#include "build.h"
|
||||
#include "dlopen-note.h"
|
||||
#include "format-table.h"
|
||||
#include "help-util.h"
|
||||
#include "log.h"
|
||||
#include "logs-show.h"
|
||||
#include "main-func.h"
|
||||
@@ -18,7 +16,6 @@
|
||||
#include "networkctl-lldp.h"
|
||||
#include "networkctl-misc.h"
|
||||
#include "networkctl-status-link.h"
|
||||
#include "options.h"
|
||||
#include "parse-argument.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
@@ -41,6 +38,13 @@ bool arg_ask_password = true;
|
||||
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_drop_in, freep);
|
||||
|
||||
COMMAND(
|
||||
"networkctl\0",
|
||||
"Query and control the networking subsystem.",
|
||||
.man_pages = "networkctl.1\0",
|
||||
.pager_flags = &arg_pager_flags,
|
||||
);
|
||||
|
||||
VERB_SCOPE(, verb_list_links, "list", "[PATTERN...]", VERB_ANY, VERB_ANY, VERB_DEFAULT|VERB_ONLINE_ONLY,
|
||||
"List links");
|
||||
VERB_SCOPE(, verb_link_status, "status", "[PATTERN...]", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY,
|
||||
@@ -76,38 +80,7 @@ VERB_SCOPE(, verb_unmask, "unmask", "FILES...",
|
||||
VERB_SCOPE(, verb_persistent_storage, "persistent-storage", "BOOL", 2, 2, 0,
|
||||
"Notify systemd-networkd if persistent storage is ready");
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_(table_unrefp) Table *verbs = NULL, *options = NULL;
|
||||
int r;
|
||||
|
||||
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);
|
||||
|
||||
help_cmdline("[OPTIONS...] COMMAND");
|
||||
help_abstract("Query and control the networking subsystem.");
|
||||
|
||||
help_section("Commands");
|
||||
r = table_print_or_warn(verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_section("Options");
|
||||
r = table_print_or_warn(options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_man_page_reference("networkctl", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
VERB_COMMON_HELP_HIDDEN(help);
|
||||
VERB_COMMON_HELP_AUTO_HIDDEN("networkctl");
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
int r;
|
||||
@@ -122,7 +95,7 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("networkctl");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -205,6 +178,9 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
OPTION_LONG("stdin", NULL, "Read new contents of edited file from stdin"):
|
||||
arg_stdin = true;
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(arg_json_format_flags);
|
||||
}
|
||||
|
||||
*remaining_args = option_parser_get_args(&opts);
|
||||
|
||||
+12
-51
@@ -1,69 +1,27 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "sd-bus.h"
|
||||
#include "sd-json.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "build.h"
|
||||
#include "bus-error.h"
|
||||
#include "bus-locator.h"
|
||||
#include "bus-message-util.h"
|
||||
#include "format-table.h"
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "options.h"
|
||||
#include "pager.h"
|
||||
#include "pretty-print.h"
|
||||
#include "verbs.h"
|
||||
|
||||
static PagerFlags arg_pager_flags = 0;
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
_cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL;
|
||||
int r;
|
||||
COMMAND(
|
||||
"oomctl\0",
|
||||
"Manage or inspect the userspace OOM killer.",
|
||||
.man_pages = "oomctl.1\0",
|
||||
.pager_flags = &arg_pager_flags,
|
||||
);
|
||||
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = terminal_urlify_man("oomctl", "1", &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"
|
||||
"%sManage or inspect the userspace OOM killer.%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("oomctl");
|
||||
|
||||
VERB_DEFAULT_NOARG(verb_dump_state, "dump", "Output the current state of systemd-oomd");
|
||||
static int verb_dump_state(int argc, char *argv[], uintptr_t _data, void *userdata) {
|
||||
@@ -96,7 +54,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("oomctl");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -104,6 +62,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);
|
||||
|
||||
+14
-38
@@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "sd-bus.h"
|
||||
#include "sd-json.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "ansi-color.h"
|
||||
@@ -16,10 +17,8 @@
|
||||
#include "format-table.h"
|
||||
#include "fs-util.h"
|
||||
#include "glyph-util.h"
|
||||
#include "help-util.h"
|
||||
#include "install.h"
|
||||
#include "main-func.h"
|
||||
#include "options.h"
|
||||
#include "os-util.h"
|
||||
#include "pager.h"
|
||||
#include "parse-argument.h"
|
||||
@@ -52,6 +51,13 @@ static RuntimeScope arg_runtime_scope = RUNTIME_SCOPE_SYSTEM;
|
||||
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_extension_images, strv_freep);
|
||||
|
||||
COMMAND(
|
||||
"portablectl\0",
|
||||
"Attach or detach portable services in the local system.",
|
||||
.man_pages = "portablectl.1\0",
|
||||
.pager_flags = &arg_pager_flags,
|
||||
);
|
||||
|
||||
static bool is_portable_managed(const char *unit) {
|
||||
return ENDSWITH_SET(unit, ".service", ".target", ".socket", ".path", ".timer");
|
||||
}
|
||||
@@ -265,7 +271,7 @@ static int maybe_reload(sd_bus **bus) {
|
||||
}
|
||||
|
||||
VERB_DEFAULT_NOARG(verb_list_images, "list",
|
||||
"List available portable service images (default)");
|
||||
"List available portable service images");
|
||||
static int verb_list_images(int argc, char *argv[], uintptr_t _data, void *userdata) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
||||
@@ -1528,40 +1534,7 @@ static int dump_profiles(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_(table_unrefp) Table *verbs = NULL, *options = NULL;
|
||||
int r;
|
||||
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
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);
|
||||
|
||||
help_cmdline("[OPTIONS…] COMMAND …");
|
||||
help_abstract("Attach or detach portable services in the local system.");
|
||||
|
||||
help_section("Commands");
|
||||
r = table_print_or_warn(verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_section("Options");
|
||||
r = table_print_or_warn(options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_man_page_reference("portablectl", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
VERB_COMMON_HELP_HIDDEN(help);
|
||||
VERB_COMMON_HELP_AUTO_HIDDEN("portablectl");
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
assert(argc >= 0);
|
||||
@@ -1575,7 +1548,7 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("portablectl");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -1692,6 +1665,9 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
OPTION_LONG("system", NULL, /* help= */ NULL):
|
||||
arg_runtime_scope = RUNTIME_SCOPE_SYSTEM;
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(SD_JSON_FORMAT_OFF);
|
||||
}
|
||||
|
||||
*remaining_args = option_parser_get_args(&opts);
|
||||
|
||||
@@ -8,21 +8,19 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sd-id128.h"
|
||||
#include "sd-json.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "build.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "format-table.h"
|
||||
#include "fs-util.h"
|
||||
#include "initrd-util.h"
|
||||
#include "io-util.h"
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "mkdir.h"
|
||||
#include "options.h"
|
||||
#include "parse-util.h"
|
||||
#include "pretty-print.h"
|
||||
#include "random-util.h"
|
||||
#include "sha256.h"
|
||||
#include "string-util.h"
|
||||
@@ -45,6 +43,12 @@ typedef enum CreditEntropy {
|
||||
|
||||
static SeedAction arg_action = _ACTION_INVALID;
|
||||
|
||||
COMMAND(
|
||||
"systemd-random-seed\0",
|
||||
"Load and save the system random seed at boot and shutdown.",
|
||||
.man_pages = "systemd-random-seed.8\0",
|
||||
);
|
||||
|
||||
static CreditEntropy may_credit(int seed_fd) {
|
||||
const char *e;
|
||||
int r;
|
||||
@@ -298,45 +302,6 @@ static int save_seed_file(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
_cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL;
|
||||
int r;
|
||||
|
||||
r = terminal_urlify_man("systemd-random-seed", "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%sLoad and save the system random seed at boot and shutdown.%s\n"
|
||||
"\nCommands:\n",
|
||||
program_invocation_short_name,
|
||||
ansi_highlight(),
|
||||
ansi_normal());
|
||||
|
||||
r = table_print_or_warn(verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
printf("\nOptions:\n");
|
||||
r = table_print_or_warn(options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
printf("\nSee the %s for details.\n", link);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VERB_FULL(verb_set_action, "load", NULL, VERB_ANY, 1, 0, ACTION_LOAD,
|
||||
"Load a random seed saved on disk into the kernel entropy pool");
|
||||
VERB_FULL(verb_set_action, "save", NULL, VERB_ANY, 1, 0, ACTION_SAVE,
|
||||
@@ -357,10 +322,13 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("systemd-random-seed");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(SD_JSON_FORMAT_OFF);
|
||||
}
|
||||
|
||||
r = dispatch_verb(option_parser_get_args(&opts), NULL);
|
||||
|
||||
+13
-36
@@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "sd-event.h"
|
||||
#include "sd-json.h"
|
||||
#include "sd-varlink.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
@@ -9,11 +10,9 @@
|
||||
#include "dirent-util.h"
|
||||
#include "dlopen-note.h"
|
||||
#include "format-table.h"
|
||||
#include "help-util.h"
|
||||
#include "json-util.h"
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "options.h"
|
||||
#include "parse-argument.h"
|
||||
#include "path-lookup.h"
|
||||
#include "recurse-dir.h"
|
||||
@@ -56,6 +55,13 @@ STATIC_DESTRUCTOR_REGISTER(arg_cert, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_trust, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_extra_headers, strv_freep);
|
||||
|
||||
COMMAND(
|
||||
"systemd-report\0",
|
||||
"Acquire metrics from local sources.",
|
||||
.man_pages = "systemd-report.1\0",
|
||||
.pager_flags = &arg_pager_flags,
|
||||
);
|
||||
|
||||
typedef struct LinkInfo {
|
||||
Context *context;
|
||||
sd_varlink *link;
|
||||
@@ -918,39 +924,7 @@ static int vl_server(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
int r;
|
||||
|
||||
_cleanup_(table_unrefp) Table *verbs = NULL, *options = NULL;
|
||||
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, options, verbs);
|
||||
|
||||
help_cmdline("[OPTIONS...] COMMAND ...");
|
||||
help_abstract("Acquire metrics from local sources.");
|
||||
help_section("Commands");
|
||||
|
||||
r = table_print_or_warn(verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_section("Options");
|
||||
|
||||
r = table_print_or_warn(options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_man_page_reference("systemd-report", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
VERB_COMMON_HELP_HIDDEN(help);
|
||||
VERB_COMMON_HELP_AUTO_HIDDEN("systemd-report");
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
int r;
|
||||
@@ -963,7 +937,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-report");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -1048,6 +1022,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
if (arg_sign_mode < 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to parse --sign= mode '%s'.", opts.arg);
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(arg_json_format_flags);
|
||||
}
|
||||
|
||||
if ((arg_url || arg_key || arg_cert || arg_trust || arg_extra_headers) && !HAVE_LIBCURL)
|
||||
|
||||
+12
-44
@@ -2,8 +2,9 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sd-json.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "ansi-color.h"
|
||||
#include "ask-password-api.h"
|
||||
#include "authenticode.h"
|
||||
#include "build.h"
|
||||
@@ -13,16 +14,13 @@
|
||||
#include "efi.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "format-table.h"
|
||||
#include "fs-util.h"
|
||||
#include "install-file.h"
|
||||
#include "io-util.h"
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "options.h"
|
||||
#include "parse-argument.h"
|
||||
#include "pe-binary.h"
|
||||
#include "pretty-print.h"
|
||||
#include "stat-util.h"
|
||||
#include "string-util.h"
|
||||
#include "time-util.h"
|
||||
@@ -48,46 +46,13 @@ STATIC_DESTRUCTOR_REGISTER(arg_private_key_source, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_signed_data, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_signed_data_signature, freep);
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
_cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL;
|
||||
int r;
|
||||
COMMAND(
|
||||
"systemd-sbsign\0",
|
||||
"Sign PE binaries for EFI Secure Boot.",
|
||||
.man_pages = "systemd-sbsign.1\0",
|
||||
);
|
||||
|
||||
r = terminal_urlify_man("systemd-sbsign", "1", &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%sSign binaries for EFI Secure Boot%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-sbsign");
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
assert(argc >= 0);
|
||||
@@ -101,7 +66,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("systemd-sbsign");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -163,6 +128,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
return r;
|
||||
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(SD_JSON_FORMAT_OFF);
|
||||
}
|
||||
|
||||
if (arg_private_key_source && !arg_certificate)
|
||||
|
||||
+10
-43
@@ -32,14 +32,11 @@
|
||||
#include "exec-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "format-table.h"
|
||||
#include "hibernate-util.h"
|
||||
#include "io-util.h"
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "options.h"
|
||||
#include "os-util.h"
|
||||
#include "pretty-print.h"
|
||||
#include "sleep-config.h"
|
||||
#include "special.h"
|
||||
#include "strv.h"
|
||||
@@ -48,6 +45,12 @@
|
||||
|
||||
#define DEFAULT_HIBERNATE_DELAY_USEC_NO_BATTERY (2 * USEC_PER_HOUR)
|
||||
|
||||
COMMAND(
|
||||
"systemd-sleep\0",
|
||||
"Suspend the system, hibernate the system, or both.",
|
||||
.man_pages = "systemd-suspend.service.8\0",
|
||||
);
|
||||
|
||||
#if ENABLE_EFI
|
||||
static int determine_auto_swap(sd_device *device) {
|
||||
_cleanup_(sd_device_unrefp) sd_device *origin = NULL;
|
||||
@@ -615,45 +618,6 @@ static int execute_s2h(const SleepConfig *sleep_config, SleepOperation main_oper
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
_cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL;
|
||||
int r;
|
||||
|
||||
r = terminal_urlify_man("systemd-suspend.service", "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%sSuspend the system, hibernate the system, or both.%s\n"
|
||||
"\nCommands:\n",
|
||||
program_invocation_short_name,
|
||||
ansi_highlight(),
|
||||
ansi_normal());
|
||||
|
||||
r = table_print_or_warn(verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
printf("\nOptions:\n");
|
||||
r = table_print_or_warn(options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
printf("\nSee the %s for details.\n", link);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VERB_FULL(verb_operate, "suspend", NULL, VERB_ANY, 1, 0, SLEEP_SUSPEND,
|
||||
"Suspend the system");
|
||||
VERB_FULL(verb_operate, "hibernate", NULL, VERB_ANY, 1, 0, SLEEP_HIBERNATE,
|
||||
@@ -735,10 +699,13 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("systemd-sleep");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(SD_JSON_FORMAT_OFF);
|
||||
}
|
||||
|
||||
*ret_args = option_parser_get_args(&opts);
|
||||
|
||||
@@ -3,18 +3,16 @@
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sd-json.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "ansi-color.h"
|
||||
#include "build.h"
|
||||
#include "fd-util.h"
|
||||
#include "format-table.h"
|
||||
#include "fs-util.h"
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "mkdir.h"
|
||||
#include "options.h"
|
||||
#include "parse-argument.h"
|
||||
#include "pretty-print.h"
|
||||
#include "ssh-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
@@ -27,6 +25,12 @@ static bool arg_issue_stdout = false;
|
||||
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_issue_path, freep);
|
||||
|
||||
COMMAND(
|
||||
"systemd-ssh-issue\0",
|
||||
"Create or remove the /run/issue.d/ file announcing the SSH VSOCK address.",
|
||||
.man_pages = "systemd-ssh-issue.1\0",
|
||||
);
|
||||
|
||||
static int acquire_cid(unsigned *ret_cid) {
|
||||
int r;
|
||||
|
||||
@@ -113,47 +117,6 @@ static int verb_rm_vsock(int argc, char *argv[], uintptr_t _data, void *_userdat
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
_cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL;
|
||||
int r;
|
||||
|
||||
r = terminal_urlify_man("systemd-ssh-issue", "1", &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%sCreate/remove ssh /run/issue.d/ file reporting VSOCK address.%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;
|
||||
}
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
assert(argc >= 0);
|
||||
assert(argv);
|
||||
@@ -167,7 +130,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("systemd-ssh-issue");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -191,6 +154,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
|
||||
arg_issue_stdout = false;
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(SD_JSON_FORMAT_OFF);
|
||||
}
|
||||
|
||||
if (!arg_issue_path && !arg_issue_stdout) {
|
||||
|
||||
@@ -16,6 +16,7 @@ executables += [
|
||||
},
|
||||
executable_template + {
|
||||
'name' : 'userdbctl',
|
||||
'public' : true,
|
||||
'conditions' : ['ENABLE_USERDB'],
|
||||
'sources' : files('userdbctl.c'),
|
||||
},
|
||||
|
||||
+14
-37
@@ -3,6 +3,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sd-json.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "ansi-color.h"
|
||||
#include "bitfield.h"
|
||||
@@ -20,13 +22,11 @@
|
||||
#include "format-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "glyph-util.h"
|
||||
#include "help-util.h"
|
||||
#include "io-util.h"
|
||||
#include "json-util.h"
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "mkdir.h"
|
||||
#include "options.h"
|
||||
#include "pager.h"
|
||||
#include "parse-argument.h"
|
||||
#include "recurse-dir.h"
|
||||
@@ -70,6 +70,13 @@ static sd_json_variant *arg_from_file = NULL;
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_services, strv_freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_from_file, sd_json_variant_unrefp);
|
||||
|
||||
COMMAND(
|
||||
"userdbctl\0",
|
||||
"Show user and group information.",
|
||||
.man_pages = "userdbctl.1\0",
|
||||
.pager_flags = &arg_pager_flags,
|
||||
);
|
||||
|
||||
static const char *output_table[_OUTPUT_MAX] = {
|
||||
[OUTPUT_CLASSIC] = "classic",
|
||||
[OUTPUT_TABLE] = "table",
|
||||
@@ -1551,40 +1558,7 @@ static int verb_load_credentials(int argc, char *argv[], uintptr_t _data, void *
|
||||
return r;
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_(table_unrefp) Table *verbs = NULL, *options = NULL;
|
||||
int r;
|
||||
|
||||
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);
|
||||
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
help_cmdline("[OPTIONS…] COMMAND …");
|
||||
help_abstract("Show user and group information.");
|
||||
|
||||
help_section("Commands");
|
||||
r = table_print_or_warn(verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_section("Options");
|
||||
r = table_print_or_warn(options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_man_page_reference("userdbctl", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
VERB_COMMON_HELP_HIDDEN(help);
|
||||
VERB_COMMON_HELP_AUTO_HIDDEN("userdbctl");
|
||||
|
||||
static int parse_from_file(const char *arg, sd_json_variant **ret) {
|
||||
sd_json_variant *v = NULL;
|
||||
@@ -1638,7 +1612,7 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("userdbctl");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -1819,6 +1793,9 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
json_variant_unref_and_replace(arg_from_file, v);
|
||||
break;
|
||||
}
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(arg_json_format_flags);
|
||||
}
|
||||
|
||||
/* When --chain was seen, stop parsing switches after the second positional argument:
|
||||
|
||||
@@ -11,7 +11,15 @@ export SYSTEMD_PAGER=cat
|
||||
|
||||
# A smoke test for the introspection code
|
||||
INTROSPECTABLE=(
|
||||
busctl
|
||||
coredumpctl
|
||||
homectl
|
||||
hostnamectl
|
||||
importctl
|
||||
localectl
|
||||
networkctl
|
||||
oomctl
|
||||
portablectl
|
||||
resolvectl
|
||||
systemd-ac-power
|
||||
systemd-analyze
|
||||
@@ -19,16 +27,20 @@ INTROSPECTABLE=(
|
||||
systemd-backlight
|
||||
systemd-battery-check
|
||||
systemd-binfmt
|
||||
systemd-bless-boot
|
||||
systemd-boot-check-no-failures
|
||||
systemd-bsod
|
||||
systemd-cat
|
||||
systemd-cgls
|
||||
systemd-cgtop
|
||||
systemd-clonesetup
|
||||
systemd-creds
|
||||
systemd-cryptsetup
|
||||
systemd-delta
|
||||
systemd-detect-virt
|
||||
systemd-dissect
|
||||
systemd-escape
|
||||
systemd-factory-reset
|
||||
systemd-firstboot
|
||||
systemd-growfs
|
||||
systemd-hibernate-resume
|
||||
@@ -39,6 +51,7 @@ INTROSPECTABLE=(
|
||||
systemd-journal-gatewayd
|
||||
systemd-journal-remote
|
||||
systemd-journal-upload
|
||||
systemd-keyutil
|
||||
systemd-modules-load
|
||||
systemd-mute-console
|
||||
systemd-network-generator
|
||||
@@ -48,8 +61,13 @@ INTROSPECTABLE=(
|
||||
systemd-path
|
||||
systemd-pcrextend
|
||||
systemd-pty-forward
|
||||
systemd-random-seed
|
||||
systemd-report
|
||||
systemd-sbsign
|
||||
systemd-sleep
|
||||
systemd-socket-activate
|
||||
systemd-socket-proxyd
|
||||
systemd-ssh-issue
|
||||
systemd-stdio-bridge
|
||||
systemd-storage-block
|
||||
systemd-storage-fs
|
||||
@@ -62,6 +80,7 @@ INTROSPECTABLE=(
|
||||
systemd-validatefs
|
||||
systemd-veritysetup
|
||||
timedatectl
|
||||
userdbctl
|
||||
varlinkctl
|
||||
)
|
||||
|
||||
@@ -77,6 +96,11 @@ for i in "${INTROSPECTABLE[@]}"; do
|
||||
$i --introspect-cli | jq -e \
|
||||
'any(.commands[]; [.options[].names[-1]] | contains(["--help", "--version", "--introspect-cli"]))'
|
||||
$i --intro | grep -e --help
|
||||
|
||||
# If the tool has a "help" verb, it must work too
|
||||
if $i --introspect-cli | jq -e 'any(.commands[]; (.verbs // []) | any(.names[0] == "help"))' >/dev/null; then
|
||||
$i help >/dev/null
|
||||
fi
|
||||
done
|
||||
|
||||
# systemd-hwdb defines verbs, check that they are described
|
||||
|
||||
Reference in New Issue
Block a user