summaryrefslogtreecommitdiff
path: root/command.c
diff options
context:
space:
mode:
authorWilliam Casarin <jb55@jb55.com>2018-07-09 17:43:46 -0700
committerWilliam Casarin <jb55@jb55.com>2018-07-09 17:43:46 -0700
commitd2ce420ae24cbdd2c61f38342bdabc19c2358947 (patch)
tree0e30ae8fe500a9d80b5a862e2ea5eddd73e9e55e /command.c
parent22e403ca533419e1d19bf5c4dad8b2bbc4eb2173 (diff)
it works yo
Diffstat (limited to 'command.c')
-rw-r--r--command.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/command.c b/command.c
index accf212..ee31b05 100644
--- a/command.c
+++ b/command.c
@@ -4,6 +4,8 @@
#include "ccan/tal/tal.h"
#include "ccan/tal/str/str.h"
#include "ccan/str/str.h"
+#include <err.h>
+#include <unistd.h>
#include "util.h"
@@ -18,6 +20,11 @@ command_is_prefix(struct command *cmd) {
return count > 0;
}
+void
+command_exec(struct command *cmd) {
+ execlp(cmd->name, cmd->name, (char *)NULL);
+ err(1, "executing command %s", cmd->name);
+}
struct command *
command_lookup(struct command *cmd, const char *binding) {
@@ -33,7 +40,7 @@ command_lookup(struct command *cmd, const char *binding) {
static const struct command examples[] = {
{ .bind = "f", .name = "firefox" },
{ .bind = "m", .name = "misc" },
- { .bind = "e", .name = "spacemacs" },
+ { .bind = "e", .name = "emacs" },
{ .bind = "N", .name = "networking" },
};
@@ -57,7 +64,7 @@ test_root_commands(tal_t *ctx) {
}
child = cmds[i].children = tal_arr(cmds, struct command, i % 2);
for (j = 0; j < tal_count(child); j++) {
- child[j].name = tal_fmt(child, "child-%d-%d", (int)i, (int)j);
+ child[j].name = "sayhi";
child[j].bind = tal_fmt(child, "%c", (int)(c+j));
child[j].children = NULL;
}