summaryrefslogtreecommitdiff
path: root/src/dged
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2024-04-03 11:43:49 +0200
committerAlbert Cervin <albert@acervin.com>2024-04-03 11:43:49 +0200
commit1ed6000dd2a995bcd67e99b1c89aa1e2c4a6f1e6 (patch)
treedff73302ddb932b1355df8cff4fcb2557a748a8e /src/dged
parent80e6ab5ec9fdb0f4a3b3fa35e4ea502a54b85e1a (diff)
downloaddged-1ed6000dd2a995bcd67e99b1c89aa1e2c4a6f1e6.tar.gz
dged-1ed6000dd2a995bcd67e99b1c89aa1e2c4a6f1e6.tar.xz
dged-1ed6000dd2a995bcd67e99b1c89aa1e2c4a6f1e6.zip
Add completion to execute
Completes on the command, not on following arguments if written directly at the prompt.
Diffstat (limited to 'src/dged')
-rw-r--r--src/dged/command.c8
-rw-r--r--src/dged/command.h4
2 files changed, 12 insertions, 0 deletions
diff --git a/src/dged/command.c b/src/dged/command.c
index 9144058..2775286 100644
--- a/src/dged/command.c
+++ b/src/dged/command.c
@@ -63,6 +63,14 @@ int32_t execute_command(struct command *command, struct commands *commands,
argc, argv);
}
+void commands_for_each(struct commands *commands,
+ void (*callback)(struct command *, void *),
+ void *userdata) {
+ HASHMAP_FOR_EACH(&commands->commands, struct command_entry * entry) {
+ callback(&entry->value, userdata);
+ }
+}
+
void command_ctx_push_arg(struct command_ctx *ctx, const char *argv) {
if (ctx->saved_argc < 64) {
ctx->saved_argv[ctx->saved_argc] = strdup(argv);
diff --git a/src/dged/command.h b/src/dged/command.h
index 956c10a..2b0f074 100644
--- a/src/dged/command.h
+++ b/src/dged/command.h
@@ -183,6 +183,10 @@ struct command *lookup_command(struct commands *commands, const char *name);
struct command *lookup_command_by_hash(struct commands *commands,
uint32_t hash);
+void commands_for_each(struct commands *commands,
+ void (*callback)(struct command *, void *),
+ void *userdata);
+
void command_ctx_push_arg(struct command_ctx *ctx, const char *argv);
void command_ctx_free(struct command_ctx *ctx);