From 40d90c9c01c8579a279f780e76f4edc2602d7926 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 2 Aug 2024 13:56:47 +0900 Subject: [PATCH] localectl: introduce -l/--full option Closes #33906. --- man/localectl.xml | 11 +++++++++++ shell-completion/bash/localectl | 2 +- shell-completion/zsh/_localectl | 1 + src/locale/localectl.c | 12 +++++++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/man/localectl.xml b/man/localectl.xml index e18462abab..be0df8cc11 100644 --- a/man/localectl.xml +++ b/man/localectl.xml @@ -166,6 +166,17 @@ The following options are understood: + + + + + + Do not ellipsize the output. + + + + + diff --git a/shell-completion/bash/localectl b/shell-completion/bash/localectl index 1717842648..4fd91d1a34 100644 --- a/shell-completion/bash/localectl +++ b/shell-completion/bash/localectl @@ -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 diff --git a/shell-completion/zsh/_localectl b/shell-completion/zsh/_localectl index 8c09841339..2504051713 100644 --- a/shell-completion/zsh/_localectl +++ b/shell-completion/zsh/_localectl @@ -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' diff --git a/src/locale/localectl.c b/src/locale/localectl.c index 5b00820e5a..4549359716 100644 --- a/src/locale/localectl.c +++ b/src/locale/localectl.c @@ -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; -- 2.25.1