diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-10-15 18:34:05 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-10-24 18:32:17 +0200 |
commit | 918560d70fb3ee8d1f4e236ac89e5eaf62aa3a71 (patch) | |
tree | 24f51475625ff81a85a02f0403ecafceb1a1f902 /src/sysusers | |
parent | tmpfiles: add --tldr (diff) | |
download | systemd-918560d70fb3ee8d1f4e236ac89e5eaf62aa3a71.tar.xz systemd-918560d70fb3ee8d1f4e236ac89e5eaf62aa3a71.zip |
sysusers: add --tldr
Diffstat (limited to 'src/sysusers')
-rw-r--r-- | src/sysusers/sysusers.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index d996583cbd..a8fa5557c5 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -94,7 +94,7 @@ typedef struct Item { static char *arg_root = NULL; static char *arg_image = NULL; -static bool arg_cat_config = false; +static CatFlags arg_cat_flags = CAT_CONFIG_OFF; static const char *arg_replace = NULL; static bool arg_dry_run = false; static bool arg_inline = false; @@ -2044,7 +2044,7 @@ static int cat_config(void) { pager_open(arg_pager_flags); - return cat_files(NULL, files, /* flags= */ 0); + return cat_files(NULL, files, arg_cat_flags); } static int help(void) { @@ -2060,6 +2060,7 @@ static int help(void) { " -h --help Show this help\n" " --version Show package version\n" " --cat-config Show configuration files\n" + " --tldr Show non-comment parts of configuration\n" " --root=PATH Operate on an alternate filesystem root\n" " --image=PATH Operate on disk image as filesystem root\n" " --image-policy=POLICY Specify disk image dissection policy\n" @@ -2079,6 +2080,7 @@ static int parse_argv(int argc, char *argv[]) { enum { ARG_VERSION = 0x100, ARG_CAT_CONFIG, + ARG_TLDR, ARG_ROOT, ARG_IMAGE, ARG_IMAGE_POLICY, @@ -2092,6 +2094,7 @@ static int parse_argv(int argc, char *argv[]) { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, ARG_VERSION }, { "cat-config", no_argument, NULL, ARG_CAT_CONFIG }, + { "tldr", no_argument, NULL, ARG_TLDR }, { "root", required_argument, NULL, ARG_ROOT }, { "image", required_argument, NULL, ARG_IMAGE }, { "image-policy", required_argument, NULL, ARG_IMAGE_POLICY }, @@ -2118,7 +2121,11 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_CAT_CONFIG: - arg_cat_config = true; + arg_cat_flags = CAT_CONFIG_ON; + break; + + case ARG_TLDR: + arg_cat_flags = CAT_TLDR; break; case ARG_ROOT: @@ -2172,16 +2179,17 @@ static int parse_argv(int argc, char *argv[]) { assert_not_reached(); } - if (arg_replace && arg_cat_config) + if (arg_replace && arg_cat_flags != CAT_CONFIG_OFF) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "Option --replace= is not supported with --cat-config"); + "Option --replace= is not supported with --cat-config/--tldr."); if (arg_replace && optind >= argc) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "When --replace= is given, some configuration items must be specified"); + "When --replace= is given, some configuration items must be specified."); if (arg_image && arg_root) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Please specify either --root= or --image=, the combination of both is not supported."); + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Use either --root= or --image=, the combination of both is not supported."); return 1; } @@ -2275,7 +2283,7 @@ static int run(int argc, char *argv[]) { log_setup(); - if (arg_cat_config) + if (arg_cat_flags != CAT_CONFIG_OFF) return cat_config(); umask(0022); |