Move -s and -c down a level so handling them is the responsibility of the command (with some helper functions), rather than the top-level. This changes the action command syntax so that -s and -c must be after the command rather than before.

This commit is contained in:
Nicholas Marriott
2008-06-02 18:08:17 +00:00
parent 11ee55e755
commit c7243b73cb
42 changed files with 1086 additions and 437 deletions

View File

@ -1,4 +1,4 @@
/* $Id: cmd-bind-key.c,v 1.8 2007-12-06 09:46:21 nicm Exp $ */
/* $Id: cmd-bind-key.c,v 1.9 2008-06-02 18:08:16 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -26,7 +26,7 @@
* Bind a key to a command, this recurses through cmd_*.
*/
int cmd_bind_key_parse(void **, int, char **, char **);
int cmd_bind_key_parse(struct cmd *, void **, int, char **, char **);
void cmd_bind_key_exec(void *, struct cmd_ctx *);
void cmd_bind_key_send(void *, struct buffer *);
void cmd_bind_key_recv(void **, struct buffer *);
@ -38,8 +38,9 @@ struct cmd_bind_key_data {
};
const struct cmd_entry cmd_bind_key_entry = {
"bind-key", "bind", "key command [arguments]",
CMD_NOCLIENT|CMD_NOSESSION,
"bind-key", "bind",
"key command [arguments]",
0,
cmd_bind_key_parse,
cmd_bind_key_exec,
cmd_bind_key_send,
@ -48,7 +49,8 @@ const struct cmd_entry cmd_bind_key_entry = {
};
int
cmd_bind_key_parse(void **ptr, int argc, char **argv, char **cause)
cmd_bind_key_parse(
struct cmd *self, void **ptr, int argc, char **argv, char **cause)
{
struct cmd_bind_key_data *data;
int opt;
@ -80,8 +82,7 @@ cmd_bind_key_parse(void **ptr, int argc, char **argv, char **cause)
return (0);
usage:
usage(cause, "%s %s",
cmd_bind_key_entry.name, cmd_bind_key_entry.usage);
usage(cause, "%s %s", self->entry->name, self->entry->usage);
error:
cmd_bind_key_free(data);