Now that parsing is common, merge some of the small, related commands

together to use the same code.

Also add some arguments (such as -n and -p) to some commands to match
existing commands.
This commit is contained in:
Nicholas Marriott
2011-01-04 02:03:41 +00:00
parent 55346b0d10
commit 96c37fa80a
18 changed files with 238 additions and 587 deletions

View File

@ -25,7 +25,7 @@
#include "tmux.h"
/*
* Lock server.
* Lock commands.
*/
int cmd_lock_server_exec(struct cmd *, struct cmd_ctx *);
@ -40,11 +40,45 @@ const struct cmd_entry cmd_lock_server_entry = {
cmd_lock_server_exec
};
const struct cmd_entry cmd_lock_session_entry = {
"lock-session", "locks",
"t:", 0, 0,
CMD_TARGET_SESSION_USAGE,
0,
NULL,
NULL,
cmd_lock_server_exec
};
const struct cmd_entry cmd_lock_client_entry = {
"lock-client", "lockc",
"t:", 0, 0,
CMD_TARGET_CLIENT_USAGE,
0,
NULL,
NULL,
cmd_lock_server_exec
};
/* ARGSUSED */
int
cmd_lock_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
cmd_lock_server_exec(struct cmd *self, unused struct cmd_ctx *ctx)
{
server_lock();
struct args *args = self->args;
struct client *c;
struct session *s;
if (self->entry == &cmd_lock_server_entry)
server_lock();
else if (self->entry == &cmd_lock_session_entry) {
if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL)
return (-1);
server_lock_session(s);
} else {
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
return (-1);
server_lock_client(c);
}
recalculate_sizes();
return (0);