diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-09-14 22:30:14 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-09-14 22:33:18 +0200 |
commit | e441d1d46e8cd640ffac9d9231e5b16852fd9c28 (patch) | |
tree | e8cd117c97347e952e1410952d7f0f553cd2aefe /src/path | |
parent | path: rename functions (diff) | |
download | systemd-e441d1d46e8cd640ffac9d9231e5b16852fd9c28.tar.xz systemd-e441d1d46e8cd640ffac9d9231e5b16852fd9c28.zip |
path: add --no-pager option, enable pager by default
When called with no argument, to list all known values, it is likely that it's
used by somebody to look at all the whole list. The output is more than a page,
so let's enable the pager.
Diffstat (limited to 'src/path')
-rw-r--r-- | src/path/path.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/path/path.c b/src/path/path.c index a02047d110..9845425d01 100644 --- a/src/path/path.c +++ b/src/path/path.c @@ -12,10 +12,12 @@ #include "log.h" #include "macro.h" #include "main-func.h" +#include "pager.h" #include "pretty-print.h" #include "string-util.h" static const char *arg_suffix = NULL; +PagerFlags arg_pager_flags = 0; static const char* const path_table[_SD_PATH_MAX] = { [SD_PATH_TEMPORARY] = "temporary", @@ -104,6 +106,8 @@ static const char* const path_table[_SD_PATH_MAX] = { static int list_paths(void) { int r = 0; + pager_open(arg_pager_flags); + for (size_t i = 0; i < ELEMENTSOF(path_table); i++) { _cleanup_free_ char *p = NULL; int q; @@ -155,6 +159,7 @@ static int help(void) { " -h --help Show this help\n" " --version Show package version\n" " --suffix=SUFFIX Suffix to append to paths\n" + " --no-pager Do not pipe output into a pager\n" "\nSee the %s for details.\n", program_invocation_short_name, link); @@ -166,12 +171,14 @@ static int parse_argv(int argc, char *argv[]) { enum { ARG_VERSION = 0x100, ARG_SUFFIX, + ARG_NO_PAGER, }; static const struct option options[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, ARG_VERSION }, { "suffix", required_argument, NULL, ARG_SUFFIX }, + { "no-pager", no_argument, NULL, ARG_NO_PAGER }, {} }; @@ -194,6 +201,10 @@ static int parse_argv(int argc, char *argv[]) { arg_suffix = optarg; break; + case ARG_NO_PAGER: + arg_pager_flags |= PAGER_DISABLE; + break; + case '?': return -EINVAL; |