diff options
author | nicm <nicm> | 2021-08-25 08:51:55 +0000 |
---|---|---|
committer | nicm <nicm> | 2021-08-25 08:51:55 +0000 |
commit | 03d173cbd8e72c356512a0e19e356b07d518627a (patch) | |
tree | 3470ea9b0d06f58f84da38ba11c5bc9c015cb941 /cmd-bind-key.c | |
parent | c6d6af49039d7fc3ec14c2240153226709497313 (diff) | |
download | rtmux-03d173cbd8e72c356512a0e19e356b07d518627a.tar.gz rtmux-03d173cbd8e72c356512a0e19e356b07d518627a.tar.bz2 rtmux-03d173cbd8e72c356512a0e19e356b07d518627a.zip |
Validate command argument types (string or command list) and give more
useful error messages.
Diffstat (limited to 'cmd-bind-key.c')
-rw-r--r-- | cmd-bind-key.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/cmd-bind-key.c b/cmd-bind-key.c index bb905bce..778d655b 100644 --- a/cmd-bind-key.c +++ b/cmd-bind-key.c @@ -27,13 +27,16 @@ * Bind a key to a command. */ -static enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmdq_item *); +static enum args_parse_type cmd_bind_key_args_parse(struct args *, u_int, + char **); +static enum cmd_retval cmd_bind_key_exec(struct cmd *, + struct cmdq_item *); const struct cmd_entry cmd_bind_key_entry = { .name = "bind-key", .alias = "bind", - .args = { "nrN:T:", 1, -1, NULL }, + .args = { "nrN:T:", 1, -1, cmd_bind_key_args_parse }, .usage = "[-nr] [-T key-table] [-N note] key " "[command [arguments]]", @@ -41,6 +44,15 @@ const struct cmd_entry cmd_bind_key_entry = { .exec = cmd_bind_key_exec }; +static enum args_parse_type +cmd_bind_key_args_parse(__unused struct args *args, u_int idx, + __unused char **cause) +{ + if (idx == 1) + return (ARGS_PARSE_COMMANDS_OR_STRING); + return (ARGS_PARSE_STRING); +} + static enum cmd_retval cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item) { |