|
| 1 | +# Commands Expose Example |
| 2 | + |
| 3 | +Demonstrates how to show the summary help of subcommands in the `--help` |
| 4 | +message of their parent command. |
| 5 | + |
| 6 | +This example was generated with: |
| 7 | + |
| 8 | +```bash |
| 9 | +$ bashly init |
| 10 | +# ... now edit src/bashly.yml to match the example ... |
| 11 | +$ bashly generate |
| 12 | +``` |
| 13 | + |
| 14 | +----- |
| 15 | + |
| 16 | +## `bashly.yml` |
| 17 | + |
| 18 | +```yaml |
| 19 | +name: cli |
| 20 | + |
| 21 | +commands: |
| 22 | +- name: init |
| 23 | + help: Start a new project |
| 24 | + |
| 25 | +- name: config |
| 26 | + help: Config management commands |
| 27 | + |
| 28 | + # Setting `expose` to true will show the summary of the subcommands when |
| 29 | + # running the help for the parent command. In this case, `config edit` and |
| 30 | + # `config show` will be displayed when running `cli --help`. |
| 31 | + expose: true |
| 32 | + commands: |
| 33 | + - name: edit |
| 34 | + help: Edit config file |
| 35 | + - name: show |
| 36 | + help: Show config file |
| 37 | + |
| 38 | +- name: server |
| 39 | + help: Server management commands |
| 40 | + |
| 41 | + # Adding a `group` works well with `expose`. In this case, `server start` and |
| 42 | + # `server stop` will be listed under `Cluster Commands`. |
| 43 | + expose: true |
| 44 | + group: Cluster |
| 45 | + |
| 46 | + commands: |
| 47 | + - name: start |
| 48 | + help: Start the server |
| 49 | + - name: stop |
| 50 | + help: Stop the server |
| 51 | + |
| 52 | +- name: container |
| 53 | + alias: c |
| 54 | + help: Container management commands |
| 55 | + expose: true |
| 56 | + group: Cluster |
| 57 | + commands: |
| 58 | + - name: exec |
| 59 | + help: Run a command in the container |
| 60 | + - name: down |
| 61 | + help: Terminate a container |
| 62 | +``` |
| 63 | +
|
| 64 | +
|
| 65 | +
|
| 66 | +## Generated script output |
| 67 | +
|
| 68 | +### `$ ./cli` |
| 69 | + |
| 70 | +```shell |
| 71 | +cli |
| 72 | +
|
| 73 | +Usage: |
| 74 | + cli [command] |
| 75 | + cli [command] --help | -h |
| 76 | + cli --version | -v |
| 77 | +
|
| 78 | +Commands: |
| 79 | + init Start a new project |
| 80 | + config Config management commands |
| 81 | + config edit Edit config file |
| 82 | + config show Show config file |
| 83 | +
|
| 84 | +Cluster Commands: |
| 85 | + server Server management commands |
| 86 | + server start Start the server |
| 87 | + server stop Stop the server |
| 88 | + container Container management commands |
| 89 | + container exec Run a command in the container |
| 90 | + container down Terminate a container |
| 91 | +
|
| 92 | +
|
| 93 | +
|
| 94 | +``` |
| 95 | + |
| 96 | +### `$ ./cli -h` |
| 97 | + |
| 98 | +```shell |
| 99 | +cli |
| 100 | +
|
| 101 | +Usage: |
| 102 | + cli [command] |
| 103 | + cli [command] --help | -h |
| 104 | + cli --version | -v |
| 105 | +
|
| 106 | +Commands: |
| 107 | + init Start a new project |
| 108 | + config Config management commands |
| 109 | + config edit Edit config file |
| 110 | + config show Show config file |
| 111 | +
|
| 112 | +Cluster Commands: |
| 113 | + server Server management commands |
| 114 | + server start Start the server |
| 115 | + server stop Stop the server |
| 116 | + container Container management commands |
| 117 | + container exec Run a command in the container |
| 118 | + container down Terminate a container |
| 119 | +
|
| 120 | +Options: |
| 121 | + --help, -h |
| 122 | + Show this help |
| 123 | +
|
| 124 | + --version, -v |
| 125 | + Show version number |
| 126 | +
|
| 127 | +
|
| 128 | +
|
| 129 | +``` |
| 130 | + |
| 131 | + |
| 132 | + |
0 commit comments