|
| 1 | +# Command Groups Example |
| 2 | + |
| 3 | +Demonstrates how to visually group commands under their own caption. This is |
| 4 | +useful for scripts that contain many commands that provide different sets of |
| 5 | +functionality. |
| 6 | + |
| 7 | +This example was generated with: |
| 8 | + |
| 9 | +```bash |
| 10 | +$ bashly init |
| 11 | +# ... now edit src/bashly.yml to match the example ... |
| 12 | +$ bashly generate |
| 13 | +``` |
| 14 | + |
| 15 | +----- |
| 16 | + |
| 17 | +## `bashly.yml` |
| 18 | + |
| 19 | +```yaml |
| 20 | +name: ftp |
| 21 | +help: Sample application with command grouping |
| 22 | +version: 0.1.0 |
| 23 | + |
| 24 | +commands: |
| 25 | +- name: download |
| 26 | + help: Download a file |
| 27 | + |
| 28 | + # By specifying a group, the `download` comnmand (and all subsequent |
| 29 | + # commands until the next `group`) will be printed under this `File` |
| 30 | + # caption. |
| 31 | + group: File |
| 32 | + |
| 33 | + args: |
| 34 | + - name: file |
| 35 | + required: true |
| 36 | + help: File to download |
| 37 | + |
| 38 | +- name: upload |
| 39 | + help: Upload a file |
| 40 | + |
| 41 | + args: |
| 42 | + - name: file |
| 43 | + required: true |
| 44 | + help: File to upload |
| 45 | + |
| 46 | +- name: login |
| 47 | + help: Write login credentials to the config file |
| 48 | + |
| 49 | + # The `login` command (and all subsequent commands) will be printed under |
| 50 | + # the `Login` caption. |
| 51 | + group: Login |
| 52 | + |
| 53 | +- name: logout |
| 54 | + help: Delete login credentials to the config file |
| 55 | +``` |
| 56 | +
|
| 57 | +
|
| 58 | +
|
| 59 | +## Generated script output |
| 60 | +
|
| 61 | +### `$ ./ftp` |
| 62 | + |
| 63 | +```shell |
| 64 | +ftp - Sample application with command grouping |
| 65 | +
|
| 66 | +Usage: |
| 67 | + ftp [command] |
| 68 | + ftp [command] --help | -h |
| 69 | + ftp --version | -v |
| 70 | +
|
| 71 | +File Commands: |
| 72 | + download Download a file |
| 73 | + upload Upload a file |
| 74 | +
|
| 75 | +Login Commands: |
| 76 | + login Write login credentials to the config file |
| 77 | + logout Delete login credentials to the config file |
| 78 | +
|
| 79 | +
|
| 80 | +
|
| 81 | +``` |
| 82 | + |
| 83 | +### `$ ./ftp -h` |
| 84 | + |
| 85 | +```shell |
| 86 | +ftp - Sample application with command grouping |
| 87 | +
|
| 88 | +Usage: |
| 89 | + ftp [command] |
| 90 | + ftp [command] --help | -h |
| 91 | + ftp --version | -v |
| 92 | +
|
| 93 | +File Commands: |
| 94 | + download Download a file |
| 95 | + upload Upload a file |
| 96 | +
|
| 97 | +Login Commands: |
| 98 | + login Write login credentials to the config file |
| 99 | + logout Delete login credentials to the config file |
| 100 | +
|
| 101 | +Options: |
| 102 | + --help, -h |
| 103 | + Show this help |
| 104 | +
|
| 105 | + --version, -v |
| 106 | + Show version number |
| 107 | +
|
| 108 | +
|
| 109 | +
|
| 110 | +``` |
| 111 | + |
| 112 | +### `$ ./ftp login` |
| 113 | + |
| 114 | +```shell |
| 115 | +# this file is located in 'src/login_command.sh' |
| 116 | +# code for 'ftp login' goes here |
| 117 | +# you can edit it freely and regenerate (it will not be overwritten) |
| 118 | +args: none |
| 119 | +
|
| 120 | +
|
| 121 | +``` |
| 122 | + |
| 123 | + |
| 124 | + |
0 commit comments