systemd-run: add --no-pager, use pager for --help
This commit is contained in:
committed by
Yu Watanabe
parent
d137f280b8
commit
63770fa1d3
@@ -565,6 +565,16 @@
|
||||
<xi:include href="standard-options.xml" xpointer="help" />
|
||||
<xi:include href="standard-options.xml" xpointer="version" />
|
||||
<xi:include href="standard-options.xml" xpointer="json" />
|
||||
|
||||
<varlistentry id='no-pager'>
|
||||
<term><option>--no-pager</option></term>
|
||||
|
||||
<listitem><para>Do not pipe output into a pager. This currently only applies to
|
||||
<option>--help</option>. (The pager is not started during normal operation.)</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v256"/>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
<para>All command line arguments after the first non-option argument become part of the command line of
|
||||
|
||||
@@ -40,7 +40,8 @@ _systemd_run() {
|
||||
--path-property --socket-property --timer-property -H --host -M --machine --expand-environment
|
||||
--background --json --job-mode
|
||||
)
|
||||
local OPTS="${opts_with_values[*]} --no-ask-password --scope -u --slice-inherit -r --remain-after-exit
|
||||
local OPTS="${opts_with_values[*]} --no-ask-password --no-pager
|
||||
--scope -u --slice-inherit -r --remain-after-exit
|
||||
--send-sighup -d --same-dir -t --pty -P --pipe -S --shell -q --quiet --ignore-failure
|
||||
--on-clock-change --on-timezone-change --no-block --wait -G --collect --user --system -h --help --version -v --verbose"
|
||||
local mode=--system
|
||||
|
||||
@@ -47,6 +47,7 @@ _arguments \
|
||||
'(-C --capsule)'{-C,--capsule=}'[Operate on capsule]:capsule' \
|
||||
'--nice=[Nice level]:nice level' \
|
||||
'--no-ask-password[Do not query the user for authentication]' \
|
||||
'--no-pager[Do not spawn a pager]' \
|
||||
'(--wait)--no-block[Do not synchronously wait for the unit start operation to finish]' \
|
||||
'--on-active=[Run after SEC seconds]:SEC' \
|
||||
'--on-boot=[Run SEC seconds after machine was booted up]:SEC' \
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "osc-context.h"
|
||||
#include "pager.h"
|
||||
#include "parse-argument.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
@@ -110,6 +111,7 @@ static char **arg_cmdline = NULL;
|
||||
static char *arg_exec_path = NULL;
|
||||
static bool arg_ignore_failure = false;
|
||||
static char *arg_background = NULL;
|
||||
static PagerFlags arg_pager_flags = 0;
|
||||
static sd_json_format_flags_t arg_json_format_flags = SD_JSON_FORMAT_OFF;
|
||||
static char *arg_shell_prompt_prefix = NULL;
|
||||
static int arg_lightweight = -1;
|
||||
@@ -133,6 +135,8 @@ static int help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
int r;
|
||||
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = terminal_urlify_man("systemd-run", "1", &link);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
@@ -177,6 +181,7 @@ static int help(void) {
|
||||
" when queueing a new job\n"
|
||||
" --ignore-failure Ignore the exit status of the invoked process\n"
|
||||
" --background=COLOR Set ANSI color for background\n"
|
||||
" --no-pager Do not pipe output into a pager\n"
|
||||
"\n%3$sPath options:%4$s\n"
|
||||
" --path-property=NAME=VALUE Set path unit property\n"
|
||||
"\n%3$sSocket options:%4$s\n"
|
||||
@@ -318,6 +323,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
ARG_JOB_MODE,
|
||||
ARG_IGNORE_FAILURE,
|
||||
ARG_BACKGROUND,
|
||||
ARG_NO_PAGER,
|
||||
ARG_JSON,
|
||||
};
|
||||
|
||||
@@ -370,6 +376,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
{ "job-mode", required_argument, NULL, ARG_JOB_MODE },
|
||||
{ "ignore-failure", no_argument, NULL, ARG_IGNORE_FAILURE },
|
||||
{ "background", required_argument, NULL, ARG_BACKGROUND },
|
||||
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
|
||||
{ "json", required_argument, NULL, ARG_JSON },
|
||||
{},
|
||||
};
|
||||
@@ -684,6 +691,10 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
return r;
|
||||
break;
|
||||
|
||||
case ARG_NO_PAGER:
|
||||
arg_pager_flags |= PAGER_DISABLE;
|
||||
break;
|
||||
|
||||
case ARG_JSON:
|
||||
r = parse_json_argument(optarg, &arg_json_format_flags);
|
||||
if (r <= 0)
|
||||
|
||||
Reference in New Issue
Block a user