[rt-commit] r133 - /redwax-tool/trunk/redwax-tool.c
rt-commit at redwax.eu
rt-commit at redwax.eu
Mon Dec 20 10:20:08 CET 2021
Author: minfrin at redwax.eu
Date: Mon Dec 20 10:20:07 2021
New Revision: 133
Log:
Split out options completion. Remove user and group
setting during completion.
Modified:
redwax-tool/trunk/redwax-tool.c
Modified: redwax-tool/trunk/redwax-tool.c
==============================================================================
--- redwax-tool/trunk/redwax-tool.c (original)
+++ redwax-tool/trunk/redwax-tool.c Mon Dec 20 10:20:07 2021
@@ -2570,6 +2570,41 @@
return r->rc;
}
+void redwax_tool_compgen_options(redwax_tool_t *r, const char *prefix)
+{
+ int i = 0;
+ int prefix_len = strlen(prefix);
+
+ /*
+ * Single dash - list all options short and long
+ */
+ if (!strcmp(prefix, "-")) {
+ while (cmdline_opts[i].name) {
+ if (cmdline_opts[i].name) {
+ apr_file_printf(r->out, "--%s \n", cmdline_opts[i].name);
+ }
+ else if (cmdline_opts[i].optch < 128) {
+ apr_file_printf(r->out, "-%c \n", (char)cmdline_opts[i].optch);
+ }
+ i++;
+ }
+ }
+
+ /*
+ * Double dash - list options with a prefix match
+ */
+ else if (!strncmp(prefix, "--", 2)) {
+ prefix_len -= 2;
+ prefix += 2;
+ while (cmdline_opts[i].name) {
+ if (!strncmp(prefix, cmdline_opts[i].name, prefix_len)) {
+ apr_file_printf(r->out, "--%s \n", cmdline_opts[i].name);
+ }
+ i++;
+ }
+ }
+}
+
int redwax_tool_compgen(redwax_tool_t *r, const char *line)
{
const char **argv;
@@ -2747,14 +2782,6 @@
redwax_set_secret_token_in(r, optarg);
break;
}
- case REDWAX_TOOL_USER_IN: {
- redwax_complete_user(r, optarg, state.isquoted);
- break;
- }
- case REDWAX_TOOL_GROUP_IN: {
- redwax_complete_group(r, optarg, state.isquoted);
- break;
- }
case REDWAX_TOOL_PEM_IN: {
redwax_dir_walk(r, optarg, &rt_run_process_pem_in);
break;
@@ -2773,14 +2800,6 @@
}
case REDWAX_TOOL_PKCS11_MODULE_OUT: {
redwax_pkcs11_module_out(r, optarg);
- break;
- }
- case REDWAX_TOOL_USER_OUT: {
- redwax_complete_user(r, optarg, state.isquoted);
- break;
- }
- case REDWAX_TOOL_GROUP_OUT: {
- redwax_complete_group(r, optarg, state.isquoted);
break;
}
}
@@ -2808,39 +2827,7 @@
if (state.intoken == REDWAX_TOKEN_INSIDE) {
- int i = 0;
- const char *prefix = opt->argv[opt->ind - 1];
- int prefix_len = strlen(prefix);
-
- /*
- * Single dash - list all options short and long
- */
- if (!strcmp(prefix, "-")) {
- while (cmdline_opts[i].name) {
- if (cmdline_opts[i].name) {
- apr_file_printf(r->out, "--%s \n", cmdline_opts[i].name);
- }
- else if (cmdline_opts[i].optch < 128) {
- apr_file_printf(r->out, "-%c \n", (char)cmdline_opts[i].optch);
- }
- i++;
- }
- }
-
- /*
- * Double dash - list options with a prefix match
- */
- else if (!strncmp(prefix, "--", 2)) {
- prefix_len -= 2;
- prefix += 2;
- while (cmdline_opts[i].name) {
- if (!strncmp(prefix, cmdline_opts[i].name, prefix_len)) {
- apr_file_printf(r->out, "--%s \n", cmdline_opts[i].name);
- }
- i++;
- }
- }
-
+ redwax_tool_compgen_options(r, opt->argv[opt->ind - 1]);
}
break;
@@ -2970,19 +2957,7 @@
*/
if (state.intoken == REDWAX_TOKEN_INSIDE) {
- int i = 0;
- const char *prefix = opt->argv[opt->ind - 1];
-
- /*
- * -- on it's own will be caught here - list all options.
- */
- if (!strcmp(prefix, "--")) {
- while (cmdline_opts[i].name) {
- apr_file_printf(r->out, "--%s \n", cmdline_opts[i].name);
- i++;
- }
- }
-
+ redwax_tool_compgen_options(r, opt->argv[opt->ind - 1]);
}
break;
More information about the rt-commit
mailing list