Skip to content

Commit

Permalink
Having fixed flags for single-character getopt options is a bit hard to
Browse files Browse the repository at this point in the history
maintain and is only going to get worse as more are used. So instead, add a new
uint64_t member to cmd_entry which is a bitmask of upper and lowercase options
accepted by the command.

This means new single character options can be used without the need to add it
explicitly to the list.
  • Loading branch information
nicm committed Jul 14, 2009
1 parent 5ccd002 commit 097b96e
Show file tree
Hide file tree
Showing 73 changed files with 264 additions and 302 deletions.
6 changes: 3 additions & 3 deletions cmd-attach-session.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: cmd-attach-session.c,v 1.26 2009-06-25 16:34:50 nicm Exp $ */
/* $Id: cmd-attach-session.c,v 1.27 2009-07-14 06:43:32 nicm Exp $ */

/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
Expand Down Expand Up @@ -29,7 +29,7 @@ int cmd_attach_session_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_attach_session_entry = {
"attach-session", "attach",
"[-d] " CMD_TARGET_SESSION_USAGE,
CMD_DFLAG|CMD_CANTNEST|CMD_STARTSERVER,
CMD_CANTNEST|CMD_STARTSERVER, CMD_CHFLAG('d'),
cmd_target_init,
cmd_target_parse,
cmd_attach_session_exec,
Expand Down Expand Up @@ -67,7 +67,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
}

if (data->flags & CMD_DFLAG)
if (data->chflags & CMD_CHFLAG('d'))
server_write_session(s, MSG_DETACH, NULL, 0);
ctx->cmdclient->session = s;

Expand Down
4 changes: 2 additions & 2 deletions cmd-bind-key.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: cmd-bind-key.c,v 1.21 2009-05-04 17:58:26 nicm Exp $ */
/* $Id: cmd-bind-key.c,v 1.22 2009-07-14 06:43:32 nicm Exp $ */

/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
Expand Down Expand Up @@ -40,7 +40,7 @@ struct cmd_bind_key_data {
const struct cmd_entry cmd_bind_key_entry = {
"bind-key", "bind",
"[-r] key command [arguments]",
0,
0, 0,
NULL,
cmd_bind_key_parse,
cmd_bind_key_exec,
Expand Down
6 changes: 3 additions & 3 deletions cmd-break-pane.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: cmd-break-pane.c,v 1.3 2009-05-18 21:01:38 nicm Exp $ */
/* $Id: cmd-break-pane.c,v 1.4 2009-07-14 06:43:32 nicm Exp $ */

/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
Expand Down Expand Up @@ -31,7 +31,7 @@ int cmd_break_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_break_pane_entry = {
"break-pane", "breakp",
CMD_PANE_WINDOW_USAGE " [-d]",
CMD_DFLAG,
0, CMD_CHFLAG('d'),
cmd_pane_init,
cmd_pane_parse,
cmd_break_pane_exec,
Expand Down Expand Up @@ -82,7 +82,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
w->name = default_window_name(w);

wl = session_attach(s, w, -1, &cause); /* can't fail */
if (!(data->flags & CMD_DFLAG))
if (!(data->chflags & CMD_CHFLAG('d')))
session_select(s, wl->idx);
layout_refresh(w, 0);

Expand Down
4 changes: 2 additions & 2 deletions cmd-choose-session.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: cmd-choose-session.c,v 1.7 2009-05-04 17:58:26 nicm Exp $ */
/* $Id: cmd-choose-session.c,v 1.8 2009-07-14 06:43:32 nicm Exp $ */

/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
Expand Down Expand Up @@ -31,7 +31,7 @@ void cmd_choose_session_callback(void *, int);
const struct cmd_entry cmd_choose_session_entry = {
"choose-session", NULL,
CMD_TARGET_WINDOW_USAGE,
0,
0, 0,
cmd_target_init,
cmd_target_parse,
cmd_choose_session_exec,
Expand Down
4 changes: 2 additions & 2 deletions cmd-choose-window.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: cmd-choose-window.c,v 1.9 2009-05-04 17:58:26 nicm Exp $ */
/* $Id: cmd-choose-window.c,v 1.10 2009-07-14 06:43:32 nicm Exp $ */

/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
Expand Down Expand Up @@ -31,7 +31,7 @@ void cmd_choose_window_callback(void *, int);
const struct cmd_entry cmd_choose_window_entry = {
"choose-window", NULL,
CMD_TARGET_WINDOW_USAGE,
0,
0, 0,
cmd_target_init,
cmd_target_parse,
cmd_choose_window_exec,
Expand Down
4 changes: 2 additions & 2 deletions cmd-clear-history.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: cmd-clear-history.c,v 1.3 2009-06-25 16:21:32 nicm Exp $ */
/* $Id: cmd-clear-history.c,v 1.4 2009-07-14 06:43:32 nicm Exp $ */

/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
Expand Down Expand Up @@ -29,7 +29,7 @@ int cmd_clear_history_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_clear_history_entry = {
"clear-history", "clearhist",
CMD_PANE_WINDOW_USAGE,
0,
0, 0,
cmd_pane_init,
cmd_pane_parse,
cmd_clear_history_exec,
Expand Down
4 changes: 2 additions & 2 deletions cmd-clock-mode.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: cmd-clock-mode.c,v 1.3 2009-01-19 18:23:40 nicm Exp $ */
/* $Id: cmd-clock-mode.c,v 1.4 2009-07-14 06:43:32 nicm Exp $ */

/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
Expand Down Expand Up @@ -29,7 +29,7 @@ int cmd_clock_mode_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_clock_mode_entry = {
"clock-mode", NULL,
CMD_TARGET_WINDOW_USAGE,
0,
0, 0,
cmd_target_init,
cmd_target_parse,
cmd_clock_mode_exec,
Expand Down
4 changes: 2 additions & 2 deletions cmd-command-prompt.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: cmd-command-prompt.c,v 1.16 2009-02-16 18:58:14 nicm Exp $ */
/* $Id: cmd-command-prompt.c,v 1.17 2009-07-14 06:43:32 nicm Exp $ */

/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
Expand Down Expand Up @@ -35,7 +35,7 @@ int cmd_command_prompt_callback(void *, const char *);
const struct cmd_entry cmd_command_prompt_entry = {
"command-prompt", NULL,
CMD_TARGET_CLIENT_USAGE " [template]",
CMD_ARG01,
CMD_ARG01, 0,
cmd_command_prompt_init,
cmd_target_parse,
cmd_command_prompt_exec,
Expand Down
4 changes: 2 additions & 2 deletions cmd-confirm-before.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: cmd-confirm-before.c,v 1.4 2009-04-28 18:29:44 tcunha Exp $ */
/* $Id: cmd-confirm-before.c,v 1.5 2009-07-14 06:43:32 nicm Exp $ */

/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
Expand Down Expand Up @@ -38,7 +38,7 @@ struct cmd_confirm_before_data {
const struct cmd_entry cmd_confirm_before_entry = {
"confirm-before", "confirm",
CMD_TARGET_CLIENT_USAGE " command",
CMD_ARG1,
CMD_ARG1, 0,
cmd_confirm_before_init,
cmd_target_parse,
cmd_confirm_before_exec,
Expand Down
4 changes: 2 additions & 2 deletions cmd-copy-buffer.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: cmd-copy-buffer.c,v 1.1 2009-02-03 17:21:19 tcunha Exp $ */
/* $Id: cmd-copy-buffer.c,v 1.2 2009-07-14 06:43:32 nicm Exp $ */

/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
Expand Down Expand Up @@ -42,7 +42,7 @@ struct cmd_copy_buffer_data {
const struct cmd_entry cmd_copy_buffer_entry = {
"copy-buffer", "copyb",
"[-a src-index] [-b dst-index] [-s src-session] [-t dst-session]",
0,
0, 0,
cmd_copy_buffer_init,
cmd_copy_buffer_parse,
cmd_copy_buffer_exec,
Expand Down
6 changes: 3 additions & 3 deletions cmd-copy-mode.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: cmd-copy-mode.c,v 1.20 2009-07-14 06:42:22 nicm Exp $ */
/* $Id: cmd-copy-mode.c,v 1.21 2009-07-14 06:43:32 nicm Exp $ */

/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
Expand Down Expand Up @@ -29,7 +29,7 @@ int cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_copy_mode_entry = {
"copy-mode", NULL,
"[-u] " CMD_TARGET_WINDOW_USAGE,
CMD_UFLAG,
0, CMD_CHFLAG('u'),
cmd_target_init,
cmd_target_parse,
cmd_copy_mode_exec,
Expand All @@ -51,7 +51,7 @@ cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
wp = wl->window->active;

window_pane_set_mode(wp, &window_copy_mode);
if (wp->mode == &window_copy_mode && data->flags & CMD_UFLAG)
if (wp->mode == &window_copy_mode && data->chflags & CMD_CHFLAG('u'))
window_copy_pageup(wp);

return (0);
Expand Down
4 changes: 2 additions & 2 deletions cmd-delete-buffer.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: cmd-delete-buffer.c,v 1.5 2009-05-04 17:58:26 nicm Exp $ */
/* $Id: cmd-delete-buffer.c,v 1.6 2009-07-14 06:43:32 nicm Exp $ */

/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
Expand Down Expand Up @@ -31,7 +31,7 @@ int cmd_delete_buffer_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_delete_buffer_entry = {
"delete-buffer", "deleteb",
CMD_BUFFER_SESSION_USAGE,
0,
0, 0,
cmd_buffer_init,
cmd_buffer_parse,
cmd_delete_buffer_exec,
Expand Down
4 changes: 2 additions & 2 deletions cmd-detach-client.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: cmd-detach-client.c,v 1.7 2009-01-19 18:23:40 nicm Exp $ */
/* $Id: cmd-detach-client.c,v 1.8 2009-07-14 06:43:32 nicm Exp $ */

/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
Expand Down Expand Up @@ -29,7 +29,7 @@ int cmd_detach_client_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_detach_client_entry = {
"detach-client", "detach",
CMD_TARGET_CLIENT_USAGE,
0,
0, 0,
cmd_target_init,
cmd_target_parse,
cmd_detach_client_exec,
Expand Down
4 changes: 2 additions & 2 deletions cmd-down-pane.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: cmd-down-pane.c,v 1.7 2009-04-01 21:10:08 nicm Exp $ */
/* $Id: cmd-down-pane.c,v 1.8 2009-07-14 06:43:32 nicm Exp $ */

/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
Expand Down Expand Up @@ -29,7 +29,7 @@ int cmd_down_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_down_pane_entry = {
"down-pane", "downp",
CMD_TARGET_WINDOW_USAGE,
0,
0, 0,
cmd_target_init,
cmd_target_parse,
cmd_down_pane_exec,
Expand Down
4 changes: 2 additions & 2 deletions cmd-find-window.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: cmd-find-window.c,v 1.10 2009-06-25 16:21:32 nicm Exp $ */
/* $Id: cmd-find-window.c,v 1.11 2009-07-14 06:43:32 nicm Exp $ */

/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
Expand Down Expand Up @@ -34,7 +34,7 @@ void cmd_find_window_callback(void *, int);
const struct cmd_entry cmd_find_window_entry = {
"find-window", "findw",
CMD_TARGET_WINDOW_USAGE " match-string",
CMD_ARG1,
CMD_ARG1, 0,
cmd_target_init,
cmd_target_parse,
cmd_find_window_exec,
Expand Down
Loading

0 comments on commit 097b96e

Please sign in to comment.