|
14 | 14 | #define FLAG(flags, help) with_help(help, EC_NODE_CMD(EC_NO_ID, flags)) |
15 | 15 | #define OPT(opts, help, ...) with_help(help, EC_NODE_CMD(EC_NO_ID, opts, __VA_ARGS__)) |
16 | 16 |
|
| 17 | +struct ec_node *grcli_options_node(void) { |
| 18 | + return EC_NODE_SUBSET( |
| 19 | + EC_NO_ID, |
| 20 | + FLAG("-h|--help", "Show usage help and exit."), |
| 21 | + OPT("-s|--socket " SOCK_PATH_ID, |
| 22 | + "Path to the control plane API socket.", |
| 23 | + ec_node("file", SOCK_PATH_ID)), |
| 24 | + FLAG("-e|--err-exit", "Abort on first error."), |
| 25 | + FLAG("-x|--trace-commands", "Print executed commands."), |
| 26 | + OPT("-f|--file PATH", |
| 27 | + "Read commands from _PATH_ instead of standard input.", |
| 28 | + ec_node("file", "PATH")), |
| 29 | + FLAG("-V|--version", "Print version and exit."), |
| 30 | + FLAG("-c|--bash-complete", "For use in bash completion."), |
| 31 | + OPT("-m|--man COMMAND", |
| 32 | + "Show man page for _COMMAND_ or list all commands if no argument.", |
| 33 | + ec_node("str", "COMMAND")) |
| 34 | + ); |
| 35 | +} |
| 36 | + |
17 | 37 | static struct ec_node *bash_complete_node(struct ec_node *cmdlist) { |
18 | 38 | return ec_node_sh_lex_expand( |
19 | 39 | EC_NO_ID, |
20 | 40 | EC_NODE_SEQ( |
21 | 41 | EC_NO_ID, |
22 | 42 | ec_node("any", "prog_name"), |
23 | | - ec_node_option( |
24 | | - EC_NO_ID, |
25 | | - EC_NODE_SUBSET( |
26 | | - EC_NO_ID, |
27 | | - FLAG("-h|--help", "Show usage help and exit."), |
28 | | - OPT("-s|--socket " SOCK_PATH_ID, |
29 | | - "Path to the control plane API socket.", |
30 | | - ec_node("file", SOCK_PATH_ID)), |
31 | | - FLAG("-e|--err-exit", "Abort on first error."), |
32 | | - FLAG("-x|--trace-commands", "Print executed commands.") |
33 | | - ) |
34 | | - ), |
| 43 | + ec_node_option(EC_NO_ID, grcli_options_node()), |
35 | 44 | cmdlist |
36 | 45 | ) |
37 | 46 | ); |
|
0 commit comments