diff options
Diffstat (limited to 'command.c')
| -rw-r--r-- | command.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -3,6 +3,7 @@ #include "ccan/tal/tal.h" #include "ccan/tal/str/str.h" +#include "ccan/str/str.h" #include "util.h" @@ -17,6 +18,18 @@ command_is_prefix(struct command *cmd) { return count > 0; } + +struct command * +command_lookup(struct command *cmd, const char *binding) { + size_t len = tal_count(cmd); + for (size_t i = 0; i < len; ++i) { + if (streq(binding, cmd[i].bind)) + return &cmd[i]; + } + + return NULL; +} + static const struct command examples[] = { { .bind = "f", .name = "firefox" }, { .bind = "m", .name = "misc" }, |
