diff options
author | nicm <nicm> | 2019-06-20 07:41:29 +0000 |
---|---|---|
committer | nicm <nicm> | 2019-06-20 07:41:29 +0000 |
commit | c1ede507d954b98a73c40665e7aee6fe5f0c5bce (patch) | |
tree | 279281ff205a0a31e27d7e6a9796aa522eb7123a /cmd-show-options.c | |
parent | cd1fc42df6d1bacac4f617e031c279ba31bc0632 (diff) | |
download | rtmux-c1ede507d954b98a73c40665e7aee6fe5f0c5bce.tar.gz rtmux-c1ede507d954b98a73c40665e7aee6fe5f0c5bce.tar.bz2 rtmux-c1ede507d954b98a73c40665e7aee6fe5f0c5bce.zip |
Add a helper function to work out option table from name.
Diffstat (limited to 'cmd-show-options.c')
-rw-r--r-- | cmd-show-options.c | 46 |
1 files changed, 2 insertions, 44 deletions
diff --git a/cmd-show-options.c b/cmd-show-options.c index 3c5b6d47..109c6c52 100644 --- a/cmd-show-options.c +++ b/cmd-show-options.c @@ -85,11 +85,11 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item) struct options *oo; enum options_table_scope scope; char *argument, *name = NULL, *cause; - const char *target; int window, idx, ambiguous, parent; struct options_entry *o; window = (self->entry == &cmd_show_window_options_entry); + if (args->argc == 0) { scope = options_scope_from_flags(args, window, fs, &oo, &cause); if (scope == OPTIONS_TABLE_NONE) { @@ -113,49 +113,7 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item) cmdq_error(item, "invalid option: %s", argument); goto fail; } - if (*name == '@') - scope = options_scope_from_flags(args, window, fs, &oo, &cause); - else { - if (options_get_only(global_options, name) != NULL) - scope = OPTIONS_TABLE_SERVER; - else if (options_get_only(global_s_options, name) != NULL) - scope = OPTIONS_TABLE_SESSION; - else if (options_get_only(global_w_options, name) != NULL) - scope = OPTIONS_TABLE_WINDOW; - else { - scope = OPTIONS_TABLE_NONE; - xasprintf(&cause, "unknown option: %s", argument); - } - if (scope == OPTIONS_TABLE_SERVER) - oo = global_options; - else if (scope == OPTIONS_TABLE_SESSION) { - if (args_has(self->args, 'g')) - oo = global_s_options; - else if (s == NULL) { - target = args_get(args, 't'); - if (target != NULL) { - cmdq_error(item, "no such session: %s", - target); - } else - cmdq_error(item, "no current session"); - goto fail; - } else - oo = s->options; - } else if (scope == OPTIONS_TABLE_WINDOW) { - if (args_has(self->args, 'g')) - oo = global_w_options; - else if (wl == NULL) { - target = args_get(args, 't'); - if (target != NULL) { - cmdq_error(item, "no such window: %s", - target); - } else - cmdq_error(item, "no current window"); - goto fail; - } else - oo = wl->window->options; - } - } + scope = options_scope_from_name(args, window, name, fs, &oo, &cause); if (scope == OPTIONS_TABLE_NONE) { if (args_has(args, 'q')) goto fail; |