localectl: introduce -l/--full option

Closes #33906.
This commit is contained in:
Yu Watanabe
2024-08-02 13:56:47 +09:00
committed by Daan De Meyer
parent 44557e03d8
commit 40d90c9c01
4 changed files with 24 additions and 2 deletions

View File

@@ -166,6 +166,17 @@
<para>The following options are understood:</para>
<variablelist>
<varlistentry>
<term><option>-l</option></term>
<term><option>--full</option></term>
<listitem>
<para>Do not ellipsize the output.</para>
<xi:include href="version-info.xml" xpointer="v257"/>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--no-ask-password</option></term>

View File

@@ -36,7 +36,7 @@ _localectl() {
local i verb comps locale_vals
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local OPTS='-h --help --version --no-convert --no-pager --no-ask-password
-H --host -M --machine'
-H --host -M --machine -l --full'
if __contains_word "$prev" $OPTS; then
case $prev in

View File

@@ -95,4 +95,5 @@ _arguments \
'--no-ask-password[Do not prompt for password]' \
'(-H --host)'{-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
'(-M --machine)'{-M+,--machine=}'[Operate on local container]:machine' \
'(-l --full)'{-l,--full}'[Do not ellipsize the output]' \
'*::localectl commands:_localectl_commands'

View File

@@ -34,6 +34,7 @@ static bool arg_ask_password = true;
static BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
static const char *arg_host = NULL;
static bool arg_convert = true;
static bool arg_full = false;
typedef struct StatusInfo {
char **locale;
@@ -76,6 +77,9 @@ static int print_status_info(StatusInfo *i) {
if (!table)
return log_oom();
if (arg_full)
table_set_width(table, 0);
assert_se(cell = table_get_cell(table, 0, 0));
(void) table_set_ellipsize_percent(table, cell, 100);
@@ -408,6 +412,7 @@ static int help(void) {
"\nOptions:\n"
" -h --help Show this help\n"
" --version Show package version\n"
" -l --full Do not ellipsize output\n"
" --no-pager Do not pipe output into a pager\n"
" --no-ask-password Do not prompt for password\n"
" -H --host=[USER@]HOST Operate on remote host\n"
@@ -438,6 +443,7 @@ static int parse_argv(int argc, char *argv[]) {
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION },
{ "full", no_argument, NULL, 'l' },
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
{ "host", required_argument, NULL, 'H' },
{ "machine", required_argument, NULL, 'M' },
@@ -451,7 +457,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
while ((c = getopt_long(argc, argv, "hH:M:", options, NULL)) >= 0)
while ((c = getopt_long(argc, argv, "hlH:M:", options, NULL)) >= 0)
switch (c) {
@@ -461,6 +467,10 @@ static int parse_argv(int argc, char *argv[]) {
case ARG_VERSION:
return version();
case 'l':
arg_full = true;
break;
case ARG_NO_CONVERT:
arg_convert = false;
break;