summaryrefslogtreecommitdiff
path: root/command.c
diff options
context:
space:
mode:
authorWilliam Casarin <jb55@jb55.com>2018-07-09 17:27:37 -0700
committerWilliam Casarin <jb55@jb55.com>2018-07-09 17:27:37 -0700
commit22e403ca533419e1d19bf5c4dad8b2bbc4eb2173 (patch)
tree089f405c4b3befd0c7d63492168cfaaf17f526a6 /command.c
parente4230b572ef598ee38da4334f0482b81496fbf0c (diff)
subtree nav works
Diffstat (limited to 'command.c')
-rw-r--r--command.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/command.c b/command.c
index 64cce58..accf212 100644
--- a/command.c
+++ b/command.c
@@ -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" },