diff options
author | nicm <nicm> | 2018-07-04 12:30:52 +0000 |
---|---|---|
committer | nicm <nicm> | 2018-07-04 12:30:52 +0000 |
commit | cc743dc296f9f8b5505ee217f15748f8d7c2b343 (patch) | |
tree | c49c9ac72e4b69406ea8fc0d99378015fdf79a19 /cmd-set-hook.c | |
parent | d254293a6d406db4b1d1d4cac36cd4225fa0d8a7 (diff) |
Add set-hook -R to run a hook immediately (useful to set multiple hooks
to the same thing).
Diffstat (limited to 'cmd-set-hook.c')
-rw-r--r-- | cmd-set-hook.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/cmd-set-hook.c b/cmd-set-hook.c index d0cd98db..b04e6335 100644 --- a/cmd-set-hook.c +++ b/cmd-set-hook.c @@ -33,8 +33,8 @@ const struct cmd_entry cmd_set_hook_entry = { .name = "set-hook", .alias = NULL, - .args = { "gt:u", 1, 2 }, - .usage = "[-gu] " CMD_TARGET_SESSION_USAGE " hook-name [command]", + .args = { "gRt:u", 1, 2 }, + .usage = "[-gRu] " CMD_TARGET_SESSION_USAGE " hook-name [command]", .target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL }, @@ -101,18 +101,21 @@ cmd_set_hook_exec(struct cmd *self, struct cmdq_item *item) else cmd = args->argv[1]; + if (cmd != NULL && (args_has(args, 'R') || args_has(args, 'u'))) { + cmdq_error(item, "no command allowed"); + return (CMD_RETURN_ERROR); + } + if (args_has(args, 'R')) { + notify_hook(item, name); + return (CMD_RETURN_NORMAL); + } if (args_has(args, 'u')) { - if (cmd != NULL) { - cmdq_error(item, "command passed to unset hook: %s", - name); - return (CMD_RETURN_ERROR); - } hooks_remove(hooks, name); return (CMD_RETURN_NORMAL); } if (cmd == NULL) { - cmdq_error(item, "no command to set hook: %s", name); + cmdq_error(item, "no command given"); return (CMD_RETURN_ERROR); } cmdlist = cmd_string_parse(cmd, NULL, 0, &cause); |