|
| 1 | +# Command Aliases Example |
| 2 | + |
| 3 | +Demonstrates how to set multiple aliases to a command. |
| 4 | + |
| 5 | +This example was generated with: |
| 6 | + |
| 7 | +```bash |
| 8 | +$ bashly init |
| 9 | +# ... now edit src/bashly.yml to match the example ... |
| 10 | +$ bashly generate |
| 11 | +``` |
| 12 | + |
| 13 | +----- |
| 14 | + |
| 15 | +## `bashly.yml` |
| 16 | + |
| 17 | +```yaml |
| 18 | +name: cli |
| 19 | +help: Sample application |
| 20 | +version: 0.1.0 |
| 21 | + |
| 22 | +environment_variables: |
| 23 | +- name: api_key |
| 24 | + help: Set your API key |
| 25 | + |
| 26 | +commands: |
| 27 | +- name: download |
| 28 | + |
| 29 | + # alias the "download" command as "d" |
| 30 | + alias: d |
| 31 | + help: Download a file |
| 32 | + |
| 33 | + args: |
| 34 | + - name: source |
| 35 | + required: true |
| 36 | + help: URL to download from |
| 37 | + - name: target |
| 38 | + help: "Target filename (default: same as source)" |
| 39 | + |
| 40 | + examples: |
| 41 | + - cli download example.com |
| 42 | + - cli d example.com ./output |
| 43 | + |
| 44 | +- name: upload |
| 45 | + |
| 46 | + # alias the "upload" command as both "u" and "push" |
| 47 | + alias: [u, push] |
| 48 | + help: Upload a file |
| 49 | + args: |
| 50 | + - name: source |
| 51 | + required: true |
| 52 | + help: File to upload |
| 53 | + |
| 54 | + examples: |
| 55 | + - cli upload README.md |
| 56 | + - cli push README.md |
| 57 | + - cli u README.md |
| 58 | +``` |
| 59 | +
|
| 60 | +
|
| 61 | +
|
| 62 | +## Generated script output |
| 63 | +
|
| 64 | +### `$ ./cli` |
| 65 | + |
| 66 | +```shell |
| 67 | +cli - Sample application |
| 68 | +
|
| 69 | +Usage: |
| 70 | + cli [command] |
| 71 | + cli [command] --help | -h |
| 72 | + cli --version | -v |
| 73 | +
|
| 74 | +Commands: |
| 75 | + download Download a file |
| 76 | + upload Upload a file |
| 77 | +
|
| 78 | +
|
| 79 | +
|
| 80 | +``` |
| 81 | + |
| 82 | +### `$ ./cli -h` |
| 83 | + |
| 84 | +```shell |
| 85 | +cli - Sample application |
| 86 | +
|
| 87 | +Usage: |
| 88 | + cli [command] |
| 89 | + cli [command] --help | -h |
| 90 | + cli --version | -v |
| 91 | +
|
| 92 | +Commands: |
| 93 | + download Download a file |
| 94 | + upload Upload a file |
| 95 | +
|
| 96 | +Options: |
| 97 | + --help, -h |
| 98 | + Show this help |
| 99 | +
|
| 100 | + --version, -v |
| 101 | + Show version number |
| 102 | +
|
| 103 | +Environment Variables: |
| 104 | + API_KEY |
| 105 | + Set your API key |
| 106 | +
|
| 107 | +
|
| 108 | +
|
| 109 | +``` |
| 110 | + |
| 111 | +### `$ ./cli download -h` |
| 112 | + |
| 113 | +```shell |
| 114 | +cli download - Download a file |
| 115 | +
|
| 116 | +Alias: d |
| 117 | +
|
| 118 | +Usage: |
| 119 | + cli download SOURCE [TARGET] |
| 120 | + cli download --help | -h |
| 121 | +
|
| 122 | +Options: |
| 123 | + --help, -h |
| 124 | + Show this help |
| 125 | +
|
| 126 | +Arguments: |
| 127 | + SOURCE |
| 128 | + URL to download from |
| 129 | +
|
| 130 | + TARGET |
| 131 | + Target filename (default: same as source) |
| 132 | +
|
| 133 | +Examples: |
| 134 | + cli download example.com |
| 135 | + cli d example.com ./output |
| 136 | +
|
| 137 | +
|
| 138 | +
|
| 139 | +``` |
| 140 | + |
| 141 | +### `$ ./cli d somefile` |
| 142 | + |
| 143 | +```shell |
| 144 | +# this file is located in 'src/download_command.sh' |
| 145 | +# code for 'cli download' goes here |
| 146 | +# you can edit it freely and regenerate (it will not be overwritten) |
| 147 | +args: |
| 148 | +- ${args[source]} = somefile |
| 149 | +
|
| 150 | +
|
| 151 | +``` |
| 152 | + |
| 153 | +### `$ ./cli upload --help` |
| 154 | + |
| 155 | +```shell |
| 156 | +cli upload - Upload a file |
| 157 | +
|
| 158 | +Alias: u, push |
| 159 | +
|
| 160 | +Usage: |
| 161 | + cli upload SOURCE |
| 162 | + cli upload --help | -h |
| 163 | +
|
| 164 | +Options: |
| 165 | + --help, -h |
| 166 | + Show this help |
| 167 | +
|
| 168 | +Arguments: |
| 169 | + SOURCE |
| 170 | + File to upload |
| 171 | +
|
| 172 | +Examples: |
| 173 | + cli upload README.md |
| 174 | + cli push README.md |
| 175 | + cli u README.md |
| 176 | +
|
| 177 | +
|
| 178 | +
|
| 179 | +``` |
| 180 | + |
| 181 | +### `$ ./cli u --help` |
| 182 | + |
| 183 | +```shell |
| 184 | +cli upload - Upload a file |
| 185 | +
|
| 186 | +Alias: u, push |
| 187 | +
|
| 188 | +Usage: |
| 189 | + cli upload SOURCE |
| 190 | + cli upload --help | -h |
| 191 | +
|
| 192 | +Options: |
| 193 | + --help, -h |
| 194 | + Show this help |
| 195 | +
|
| 196 | +Arguments: |
| 197 | + SOURCE |
| 198 | + File to upload |
| 199 | +
|
| 200 | +Examples: |
| 201 | + cli upload README.md |
| 202 | + cli push README.md |
| 203 | + cli u README.md |
| 204 | +
|
| 205 | +
|
| 206 | +
|
| 207 | +``` |
| 208 | + |
| 209 | +### `$ ./cli push somefile` |
| 210 | + |
| 211 | +```shell |
| 212 | +# this file is located in 'src/upload_command.sh' |
| 213 | +# code for 'cli upload' goes here |
| 214 | +# you can edit it freely and regenerate (it will not be overwritten) |
| 215 | +args: |
| 216 | +- ${args[source]} = somefile |
| 217 | +
|
| 218 | +
|
| 219 | +``` |
| 220 | + |
| 221 | + |
| 222 | + |
0 commit comments