|
31 | 31 |
|
32 | 32 | const char *applet = NULL; |
33 | 33 | const char *extraopts = NULL; |
34 | | -const char getoptstring[] = "cdDe:ilr:INsSZ" getoptstring_COMMON; |
35 | | -const struct option longopts[] = { |
36 | | - { "debug", 0, NULL, 'd' }, |
37 | | - { "nodeps", 0, NULL, 'D' }, |
38 | | - { "exists", 1, NULL, 'e' }, |
39 | | - { "ifcrashed", 0, NULL, 'c' }, |
40 | | - { "ifexists", 0, NULL, 'i' }, |
41 | | - { "ifinactive", 0, NULL, 'I' }, |
42 | | - { "ifnotstarted", 0, NULL, 'N' }, |
43 | | - { "ifstarted", 0, NULL, 's' }, |
44 | | - { "ifstopped", 0, NULL, 'S' }, |
45 | | - { "list", 0, NULL, 'l' }, |
46 | | - { "resolve", 1, NULL, 'r' }, |
47 | | - { "dry-run", 0, NULL, 'Z' }, |
48 | | - longopts_COMMON |
49 | | -}; |
50 | | -const char * const longopts_help[] = { |
51 | | - "set xtrace when running the command", |
52 | | - "ignore dependencies", |
53 | | - "tests if the service exists or not", |
54 | | - "if the service is crashed run the command", |
55 | | - "if the service exists run the command", |
56 | | - "if the service is inactive run the command", |
57 | | - "if the service is not started run the command", |
58 | | - "if the service is started run the command", |
59 | | - "if the service is stopped run the command", |
60 | | - "list all available services", |
61 | | - "resolve the service name to an init script", |
62 | | - "dry run (show what would happen)", |
63 | | - longopts_help_COMMON |
64 | | -}; |
| 34 | +#define opts(opt, opt_long) \ |
| 35 | + opt(d, debug, no_argument, "set xtrace when running the command") \ |
| 36 | + opt(D, nodeps, no_argument, "ignore dependencies") \ |
| 37 | + opt(e, exists, required_argument, "tests if the service exists or not") \ |
| 38 | + opt(c, ifcrashed, no_argument, "if the service is crashed run the command") \ |
| 39 | + opt(i, ifexists, no_argument, "if the service exists run the command") \ |
| 40 | + opt(I, ifinactive, no_argument, "if the service is inactive run the command") \ |
| 41 | + opt(N, ifnotstarted, no_argument, "if the service is not started run the command") \ |
| 42 | + opt(s, ifstarted, no_argument, "if the service is started run the command") \ |
| 43 | + opt(S, ifstopped, no_argument, "if the service is stopped run the command") \ |
| 44 | + opt(l, list, no_argument, "list all available services") \ |
| 45 | + opt(r, resolve, required_argument, "resolve the service name to an init script") \ |
| 46 | + opt(Z, dry-run, no_argument, "dry run (show what would happen)") |
| 47 | +cmdline_opts(opts) |
| 48 | + |
65 | 49 | const char *usagestring = "" |
66 | 50 | "Usage: rc-service [options] [-i] <service> <cmd>...\n" |
67 | 51 | " or: rc-service [options] -e <service>\n" |
|
0 commit comments