aboutsummaryrefslogtreecommitdiff
path: root/cmd-show-options.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2012-03-03 09:16:52 +0000
committerTiago Cunha <tcunha@gmx.com>2012-03-03 09:16:52 +0000
commit95f427c34e4db9d7456d2d747e6cd6b54d8badcc (patch)
treeac12c6644586d639352118b7c1c583e33edc75ec /cmd-show-options.c
parente0d22218798d1218d88cb095d251df12d3ebbc35 (diff)
downloadrtmux-95f427c34e4db9d7456d2d747e6cd6b54d8badcc.tar.gz
rtmux-95f427c34e4db9d7456d2d747e6cd6b54d8badcc.tar.bz2
rtmux-95f427c34e4db9d7456d2d747e6cd6b54d8badcc.zip
Sync OpenBSD patchset 1032:
Allow a single option to be specified to show-options to show just that option.
Diffstat (limited to 'cmd-show-options.c')
-rw-r--r--cmd-show-options.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/cmd-show-options.c b/cmd-show-options.c
index 397b0c9c..3abb5643 100644
--- a/cmd-show-options.c
+++ b/cmd-show-options.c
@@ -31,8 +31,8 @@ int cmd_show_options_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_show_options_entry = {
"show-options", "show",
- "gst:w", 0, 0,
- "[-gsw] [-t target-session|target-window]",
+ "gst:w", 0, 1,
+ "[-gsw] [-t target-session|target-window] [option]",
0,
NULL,
NULL,
@@ -41,8 +41,8 @@ const struct cmd_entry cmd_show_options_entry = {
const struct cmd_entry cmd_show_window_options_entry = {
"show-window-options", "showw",
- "gt:", 0, 0,
- "[-g] " CMD_TARGET_WINDOW_USAGE,
+ "gt:", 0, 1,
+ "[-g] " CMD_TARGET_WINDOW_USAGE " [option]",
0,
NULL,
NULL,
@@ -86,11 +86,27 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
}
}
- for (oe = table; oe->name != NULL; oe++) {
+ if (args->argc != 0) {
+ table = oe = NULL;
+ if (options_table_find(args->argv[0], &table, &oe) != 0) {
+ ctx->error(ctx, "ambiguous option: %s", args->argv[0]);
+ return (-1);
+ }
+ if (oe == NULL) {
+ ctx->error(ctx, "unknown option: %s", args->argv[0]);
+ return (-1);
+ }
if ((o = options_find1(oo, oe->name)) == NULL)
- continue;
+ return (0);
optval = options_table_print_entry(oe, o);
ctx->print(ctx, "%s %s", oe->name, optval);
+ } else {
+ for (oe = table; oe->name != NULL; oe++) {
+ if ((o = options_find1(oo, oe->name)) == NULL)
+ continue;
+ optval = options_table_print_entry(oe, o);
+ ctx->print(ctx, "%s %s", oe->name, optval);
+ }
}
return (0);