]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
keymgr: add an option for turning colorization off
authorDavid Vašek <david.vasek@nic.cz>
Tue, 17 Aug 2021 20:41:53 +0000 (22:41 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Wed, 25 Aug 2021 15:20:56 +0000 (17:20 +0200)
doc/man/keymgr.8in
doc/man_keymgr.rst
src/utils/keymgr/main.c

index 98d8a9423f63b0730ba73e417a64cc92ba6bc56e..de786632fcfd4557ef79e0f67fd87d5e773cefb7 100644 (file)
@@ -60,11 +60,17 @@ TSIG key is only displayed on \fIstdout\fP: the command does not create a file,
 key in a keystore.
 .TP
 \fB\-b\fP, \fB\-\-brief\fP
-List keys briefly. Output to a terminal is colorized.
+List keys briefly. Output to a terminal is colorized by default.
 .TP
 \fB\-l\fP, \fB\-\-list\fP
 Print the list of zones that have at least one key stored in the configured KASP
 database.
+.TP
+\fB\-x\fP, \fB\-\-mono\fP
+Don\(aqt generate colorized output.
+.TP
+\fB\-X\fP, \fB\-\-color\fP
+Force colorized output in the \fB\-\-brief\fP mode.
 .UNINDENT
 .SS Config options
 .INDENT 0.0
index 5edba45280dd17bcfd431f95a70561b31de8b3b6..19844bc0d3b31df07c7eb5cfa5178c3a16f48bbb 100644 (file)
@@ -37,12 +37,18 @@ Basic options
   key in a keystore.
 
 **-b**, **--brief**
-  List keys briefly. Output to a terminal is colorized.
+  List keys briefly. Output to a terminal is colorized by default.
 
 **-l**, **--list**
   Print the list of zones that have at least one key stored in the configured KASP
   database.
 
+**-x**, **--mono**
+  Don't generate colorized output.
+
+**-X**, **--color**
+  Force colorized output in the **--brief** mode.
+
 Config options
 ..............
 
index b1629323acc92812a79aca0573e2d8e8aaa01286..015603d738448cf57f09c6010fbaa1506567feed 100644 (file)
@@ -50,6 +50,8 @@ static void print_help(void)
               "  -d, --dir <path>         Use specified KASP database path and default configuration.\n"
               "  -t, --tsig <name> [alg]  Generate a TSIG key.\n"
               "  -l, --list               List all zones that have at least one key in KASP database.\n"
+              "  -x, --mono               Don't color the output.\n"
+              "  -X, --color              Force output colorization in the --brief mode.\n"
               "  -h, --help               Print the program help.\n"
               "  -V, --version            Print the program version.\n"
               "\n"
@@ -371,6 +373,8 @@ int main(int argc, char *argv[])
                { "tsig",    required_argument, NULL, 't' },
                { "brief",   no_argument,       NULL, 'b' },
                { "list",    no_argument,       NULL, 'l' },
+               { "mono",    no_argument,       NULL, 'x' },
+               { "color",   no_argument,       NULL, 'X' },
                { "help",    no_argument,       NULL, 'h' },
                { "version", no_argument,       NULL, 'V' },
                { NULL }
@@ -382,8 +386,10 @@ int main(int argc, char *argv[])
        bool just_list = false;
        keymgr_list_params_t list_params = { 0 };
 
+       list_params.color = isatty(STDOUT_FILENO);
+
        int opt = 0, parm = 0;
-       while ((opt = getopt_long(argc, argv, "hVd:c:C:t:lb", opts, NULL)) != -1) {
+       while ((opt = getopt_long(argc, argv, "hVd:c:C:t:lbxX", opts, NULL)) != -1) {
                switch (opt) {
                case 'h':
                        print_help();
@@ -423,7 +429,12 @@ int main(int argc, char *argv[])
                        break;
                case 'b':
                        list_params.brief = true;
-                       list_params.color = isatty(STDOUT_FILENO);
+                       break;
+               case 'x':
+                       list_params.color = false;
+                       break;
+               case 'X':
+                       list_params.color = true;
                        break;
                default:
                        print_help();