|
| 1 | +# Commands Deep Help 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 `deep_help` to true will show the summary of the commands when |
| 29 | + # running the help for this command. In this case, `config edit` and |
| 30 | + # `config show` will be displayed when running `cli --help`. |
| 31 | + deep_help: 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 `deep_help`. |
| 42 | + deep_help: true |
| 43 | + group: Cluster |
| 44 | + commands: |
| 45 | + - name: start |
| 46 | + help: Start the server |
| 47 | + - name: stop |
| 48 | + help: Stop the server |
| 49 | + |
| 50 | +- name: container |
| 51 | + alias: c |
| 52 | + help: Container management commands |
| 53 | + deep_help: true |
| 54 | + group: Cluster |
| 55 | + commands: |
| 56 | + - name: exec |
| 57 | + help: Run a command in the container |
| 58 | + - name: down |
| 59 | + help: Terminate a container |
| 60 | +``` |
| 61 | +
|
| 62 | +
|
| 63 | +
|
| 64 | +## Generated script output |
| 65 | +
|
| 66 | +### `$ ./cli` |
| 67 | + |
| 68 | +```shell |
| 69 | +cli |
| 70 | +
|
| 71 | +Usage: |
| 72 | + cli [command] |
| 73 | + cli [command] --help | -h |
| 74 | + cli --version | -v |
| 75 | +
|
| 76 | +Commands: |
| 77 | + init Start a new project |
| 78 | + config Config management commands |
| 79 | + config edit Edit config file |
| 80 | + config show Show config file |
| 81 | +
|
| 82 | +Cluster Commands: |
| 83 | + server Server management commands |
| 84 | + server start Start the server |
| 85 | + server stop Stop the server |
| 86 | + container Container management commands |
| 87 | + container exec Run a command in the container |
| 88 | + container down Terminate a container |
| 89 | +
|
| 90 | +
|
| 91 | +
|
| 92 | +``` |
| 93 | + |
| 94 | +### `$ ./cli -h` |
| 95 | + |
| 96 | +```shell |
| 97 | +cli |
| 98 | +
|
| 99 | +Usage: |
| 100 | + cli [command] |
| 101 | + cli [command] --help | -h |
| 102 | + cli --version | -v |
| 103 | +
|
| 104 | +Commands: |
| 105 | + init Start a new project |
| 106 | + config Config management commands |
| 107 | + config edit Edit config file |
| 108 | + config show Show config file |
| 109 | +
|
| 110 | +Cluster Commands: |
| 111 | + server Server management commands |
| 112 | + server start Start the server |
| 113 | + server stop Stop the server |
| 114 | + container Container management commands |
| 115 | + container exec Run a command in the container |
| 116 | + container down Terminate a container |
| 117 | +
|
| 118 | +Options: |
| 119 | + --help, -h |
| 120 | + Show this help |
| 121 | +
|
| 122 | + --version, -v |
| 123 | + Show version number |
| 124 | +
|
| 125 | +
|
| 126 | +
|
| 127 | +``` |
| 128 | + |
| 129 | + |
| 130 | + |
0 commit comments