mirror of
https://github.com/systemd/systemd.git
synced 2025-02-02 13:47:27 +03:00
binfmt: add --tldr
This commit is contained in:
parent
f80f5dd6cc
commit
5737c890d6
@ -52,6 +52,7 @@
|
||||
</varlistentry>
|
||||
|
||||
<xi:include href="standard-options.xml" xpointer="cat-config" />
|
||||
<xi:include href="standard-options.xml" xpointer="tldr" />
|
||||
<xi:include href="standard-options.xml" xpointer="no-pager" />
|
||||
<xi:include href="standard-options.xml" xpointer="help" />
|
||||
<xi:include href="standard-options.xml" xpointer="version" />
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
|
||||
static bool arg_cat_config = false;
|
||||
static CatFlags arg_cat_flags = CAT_CONFIG_OFF;
|
||||
static PagerFlags arg_pager_flags = 0;
|
||||
static bool arg_unregister = false;
|
||||
|
||||
@ -106,6 +106,12 @@ static int apply_file(const char *filename, bool ignore_enoent) {
|
||||
return r;
|
||||
}
|
||||
|
||||
static int cat_config(char **files) {
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
return cat_files(NULL, files, arg_cat_flags);
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
int r;
|
||||
@ -119,6 +125,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"
|
||||
" --no-pager Do not pipe output into a pager\n"
|
||||
" --unregister Unregister all existing entries\n"
|
||||
"\nSee the %s for details.\n",
|
||||
@ -132,6 +139,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
enum {
|
||||
ARG_VERSION = 0x100,
|
||||
ARG_CAT_CONFIG,
|
||||
ARG_TLDR,
|
||||
ARG_NO_PAGER,
|
||||
ARG_UNREGISTER,
|
||||
};
|
||||
@ -140,6 +148,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 },
|
||||
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
|
||||
{ "unregister", no_argument, NULL, ARG_UNREGISTER },
|
||||
{}
|
||||
@ -161,7 +170,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_NO_PAGER:
|
||||
@ -179,9 +192,9 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if ((arg_unregister || arg_cat_config) && argc > optind)
|
||||
if ((arg_unregister || arg_cat_flags != CAT_CONFIG_OFF) && argc > optind)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Positional arguments are not allowed with --cat-config or --unregister");
|
||||
"Positional arguments are not allowed with --cat-config/--tldr or --unregister.");
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -229,11 +242,8 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate binfmt.d files: %m");
|
||||
|
||||
if (arg_cat_config) {
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
return cat_files(NULL, files, /* flags= */ 0);
|
||||
}
|
||||
if (arg_cat_flags != CAT_CONFIG_OFF)
|
||||
return cat_config(files);
|
||||
|
||||
r = binfmt_mounted_warn();
|
||||
if (r <= 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user