diff --git a/doc/man/keymgr.8in b/doc/man/keymgr.8in index d2f86b3f29df273d324aa15483d94ebfd86b48a4..77a1ac4a0e28e5e68d5f94160af6096c800be25f 100644 --- a/doc/man/keymgr.8in +++ b/doc/man/keymgr.8in @@ -73,14 +73,14 @@ key in a keystore. Print the list of zones that have at least one key stored in the configured KASP database. .TP -\fB\-b\fP, \fB\-\-brief\fP -List keys briefly. Output to a terminal is colorized by default. -.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. +Force colorized output in the normal mode. +.TP +\fB\-v\fP, \fB\-\-version\fP +Listing of keys with full description. .TP \fB\-h\fP, \fB\-\-help\fP Print the program help. diff --git a/doc/man_keymgr.rst b/doc/man_keymgr.rst index efa0444f0e694935cdc156d8419c9399777479ae..0417c30657a79fe6febaed56d5fde322e7922889 100644 --- a/doc/man_keymgr.rst +++ b/doc/man_keymgr.rst @@ -50,14 +50,14 @@ Options Print the list of zones that have at least one key stored in the configured KASP database. -**-b**, **--brief** - List keys briefly. Output to a terminal is colorized by default. - **-x**, **--mono** Don't generate colorized output. **-X**, **--color** - Force colorized output in the **--brief** mode. + Force colorized output in the normal mode. + +**-v**, **--version** + Listing of keys with full description. **-h**, **--help** Print the program help. diff --git a/src/utils/keymgr/functions.c b/src/utils/keymgr/functions.c index a12f6cfed212e474fb57fdb1c96017e3c57bf933..9bf0bc145bbbb0394cb6bc7dac982c9530e423d6 100644 --- a/src/utils/keymgr/functions.c +++ b/src/utils/keymgr/functions.c @@ -937,7 +937,12 @@ int keymgr_list_keys(kdnssec_ctx_t *ctx, keymgr_list_params_t *params) if (ctx->zone->num_keys == 0) { return KNOT_EOK; } - if (params->brief) { + if (params->verbose) { + for (size_t i = 0; i < ctx->zone->num_keys; i++) { + knot_kasp_key_t *key = &ctx->zone->keys[i]; + print_key_full(key, params->format); + } + } else { key_sort_item_t items[ctx->zone->num_keys]; for (size_t i = 0; i < ctx->zone->num_keys; i++) { knot_kasp_key_t *key = &ctx->zone->keys[i]; @@ -952,11 +957,6 @@ int keymgr_list_keys(kdnssec_ctx_t *ctx, keymgr_list_params_t *params) for (size_t i = 0; i < ctx->zone->num_keys; i++) { print_key_brief(items[i].key, params); } - } else { - for (size_t i = 0; i < ctx->zone->num_keys; i++) { - knot_kasp_key_t *key = &ctx->zone->keys[i]; - print_key_full(key, params->format); - } } return KNOT_EOK; } diff --git a/src/utils/keymgr/functions.h b/src/utils/keymgr/functions.h index 3e07eefd7592752591ddbd19ba1b3802b746af79..4c42f19553ef1fca94db1adb39b47024f1ddea91 100644 --- a/src/utils/keymgr/functions.h +++ b/src/utils/keymgr/functions.h @@ -22,7 +22,7 @@ typedef struct { knot_time_print_t format; - bool brief; + bool verbose; bool color; } keymgr_list_params_t; diff --git a/src/utils/keymgr/main.c b/src/utils/keymgr/main.c index 0f29115bd04b0cc862fe0ee805d80238cb6eb2e7..5d1c2ab10bf216f7884901a69784b72ba8cb1aff 100644 --- a/src/utils/keymgr/main.c +++ b/src/utils/keymgr/main.c @@ -44,9 +44,9 @@ static void print_help(void) " -D, --dir <path> Path to a KASP database directory, use 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" - " -b, --brief List keys briefly.\n" " -x, --mono Don't color the output.\n" - " -X, --color Force output colorization in the --brief mode.\n" + " -X, --color Force output colorization in the normal mode.\n" + " -v, --verbose Listing of keys with full description.\n" " -h, --help Print the program help.\n" " -V, --version Print the program version.\n" "\n" @@ -296,9 +296,10 @@ int main(int argc, char *argv[]) { "dir", required_argument, NULL, 'D' }, { "tsig", required_argument, NULL, 't' }, { "list", no_argument, NULL, 'l' }, - { "brief", no_argument, NULL, 'b' }, + { "brief", no_argument, NULL, 'b' }, // Legacy. { "mono", no_argument, NULL, 'x' }, { "color", no_argument, NULL, 'X' }, + { "verbose", no_argument, NULL, 'v' }, { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, { NULL } @@ -313,7 +314,7 @@ int main(int argc, char *argv[]) list_params.color = isatty(STDOUT_FILENO); int opt = 0, parm = 0; - while ((opt = getopt_long(argc, argv, "c:C:D:t:lbxXhV", opts, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, "c:C:D:t:lbxXvhV", opts, NULL)) != -1) { switch (opt) { case 'c': if (util_conf_init_file(optarg) != KNOT_EOK) { @@ -344,7 +345,7 @@ int main(int argc, char *argv[]) just_list = true; break; case 'b': - list_params.brief = true; + WARN2("option '--brief' is deprecated and enabled by default\n"); break; case 'x': list_params.color = false; @@ -352,6 +353,9 @@ int main(int argc, char *argv[]) case 'X': list_params.color = true; break; + case 'v': + list_params.verbose = true; + break; case 'h': print_help(); goto success; diff --git a/tests-extra/tests/catalog/basic/test.py b/tests-extra/tests/catalog/basic/test.py index 49e43254d1e65520c249e4f57bd335a9727f4f0b..13b228850c59c29e610e27c1f5b148a1edd8a1ba 100644 --- a/tests-extra/tests/catalog/basic/test.py +++ b/tests-extra/tests/catalog/basic/test.py @@ -14,7 +14,8 @@ import subprocess import random def check_keys(server, zone_name, expect_keys): - cmd = Popen([dnstest.params.keymgr_bin, "-D", server.dir + "/keys", zone_name, "list"], stdout=PIPE, stderr=PIPE, universal_newlines=True) + cmd = Popen([dnstest.params.keymgr_bin, "-D", server.dir + "/keys", zone_name, "list", "-v"], \ + stdout=PIPE, stderr=PIPE, universal_newlines=True) (stdout, stderr) = cmd.communicate() lines = len(stdout.splitlines()) if lines != expect_keys: diff --git a/tests-extra/tests/catalog/groups/test.py b/tests-extra/tests/catalog/groups/test.py index 9ef9705b40b31894579a53bf5900f82450d3c118..ec7f3b9b5b61d5d616da2f467d53aefeb26f3cc0 100644 --- a/tests-extra/tests/catalog/groups/test.py +++ b/tests-extra/tests/catalog/groups/test.py @@ -14,7 +14,7 @@ import subprocess import random def check_keys(server, zone_name, expect_keys): - cmd = Popen([dnstest.params.keymgr_bin, "-D", server.dir + "/keys", zone_name, "list"], \ + cmd = Popen([dnstest.params.keymgr_bin, "-D", server.dir + "/keys", zone_name, "list", "-v"], \ stdout=PIPE, stderr=PIPE, universal_newlines=True) (stdout, stderr) = cmd.communicate() lines = len(stdout.splitlines()) diff --git a/tests-extra/tools/dnstest/keys.py b/tests-extra/tools/dnstest/keys.py index 58f385aedf5e5bf1137cff08a694ded3a9ac172a..8259d21515efa3895cc75b4406bb8bd39eb4744d 100644 --- a/tests-extra/tools/dnstest/keys.py +++ b/tests-extra/tools/dnstest/keys.py @@ -90,7 +90,7 @@ class Keymgr(object): def run(cls, conf_file, *args): cmdline = [dnstest.params.keymgr_bin] if conf_file: - cmdline += ["-c", conf_file] + cmdline += ["-c", conf_file, "-v"] cmdline += list(args) cmd = Popen(cmdline, stdout=PIPE, stderr=PIPE, universal_newlines=True)