localectl: introduce -l/--full option
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 2 Aug 2024 04:56:47 +0000 (13:56 +0900)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 2 Aug 2024 07:33:46 +0000 (09:33 +0200)
Closes #33906.

man/localectl.xml
shell-completion/bash/localectl
shell-completion/zsh/_localectl
src/locale/localectl.c

index e18462abab187721f827c99ad2c9d89d58da8aa6..be0df8cc118ec19410a080b5586c57c85e8765bd 100644 (file)
     <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>
 
index 1717842648b9fd08317c798219d4bfb4aa0de8ac..4fd91d1a340ae71a38843b3e107dd52ae669068d 100644 (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
index 8c098413394b1da5434f9ecd9f47740cf058a884..25040517138d0c972865004151bb10900c43c473 100644 (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'
index 5b00820e5a575745067668288caf42b0279819d6..454935971693495588e069e49f80dd912e9331b1 100644 (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;