1 #include "xdo_cmd.h"
2
cmd_windowquit(context_t * context)3 int cmd_windowquit(context_t *context) {
4 int ret = 0;
5 char *cmd = *context->argv;
6 const char *window_arg = "%1";
7
8 int c;
9 static struct option longopts[] = {
10 { "help", no_argument, NULL, 'h' },
11 { 0, 0, 0, 0 },
12 };
13 static const char *usage =
14 "Usage: %s [window=%1]\n"
15 HELP_SEE_WINDOW_STACK;
16 int option_index;
17
18 while ((c = getopt_long_only(context->argc, context->argv, "+h",
19 longopts, &option_index)) != -1) {
20 switch (c) {
21 case 'h':
22 printf(usage, cmd);
23 consume_args(context, context->argc);
24 return EXIT_SUCCESS;
25 break;
26 default:
27 fprintf(stderr, usage, cmd);
28 return EXIT_FAILURE;
29 }
30 }
31
32 consume_args(context, optind);
33
34 if (!window_get_arg(context, 0, 0, &window_arg)) {
35 fprintf(stderr, usage, cmd);
36 return EXIT_FAILURE;
37 }
38
39 window_each(context, window_arg, {
40 ret = xdo_quit_window(context->xdo, window);
41 if (ret) {
42 fprintf(stderr, "xdo_quit_window reported an error on window %ld\n",
43 window);
44 }
45 }); /* window_each(...) */
46
47 return ret;
48 } /* int cmd_windowquit(context_t *) */
49
50