|
| 1 | +# Colors Usage Example |
| 2 | + |
| 3 | +This example demonstrates how to apply colors to various usage elements. |
| 4 | + |
| 5 | +This example was generated with: |
| 6 | + |
| 7 | +```bash |
| 8 | +$ bashly init |
| 9 | +$ bashly add colors |
| 10 | +$ bashly add settings |
| 11 | +# ... now edit settings.yml to match the example ... |
| 12 | +$ bashly generate |
| 13 | +``` |
| 14 | + |
| 15 | +The `bashly add colors` command, simply created the [src/lib/colors.sh] |
| 16 | +(src/lib/colors.sh) file, with useful color functions that will be |
| 17 | +automatically included in the generated script. |
| 18 | + |
| 19 | +The manually modified `settings.yml` file specifies which color function is |
| 20 | +used for which usage element. |
| 21 | + |
| 22 | +Note that the output displayed in this README is not colored. |
| 23 | + |
| 24 | +<!-- include: settings.yml --> |
| 25 | + |
| 26 | +----- |
| 27 | + |
| 28 | +## `bashly.yml` |
| 29 | + |
| 30 | +```yaml |
| 31 | +name: cli |
| 32 | +help: Sample application |
| 33 | +version: 0.1.0 |
| 34 | + |
| 35 | +environment_variables: |
| 36 | +- name: api_key |
| 37 | + help: Set your API key |
| 38 | + |
| 39 | +commands: |
| 40 | +- name: download |
| 41 | + alias: d |
| 42 | + help: Download a file |
| 43 | + |
| 44 | + args: |
| 45 | + - name: source |
| 46 | + required: true |
| 47 | + help: URL to download from |
| 48 | + - name: target |
| 49 | + help: "Target filename (default: same as source)" |
| 50 | + |
| 51 | + flags: |
| 52 | + - long: --force |
| 53 | + short: -f |
| 54 | + help: Overwrite existing files |
| 55 | + |
| 56 | + examples: |
| 57 | + - cli download example.com |
| 58 | + - cli download example.com ./output -f |
| 59 | + |
| 60 | + environment_variables: |
| 61 | + - name: default_target_location |
| 62 | + help: Set the default location to download to |
| 63 | + |
| 64 | +- name: upload |
| 65 | + alias: u |
| 66 | + help: Upload a file |
| 67 | + args: |
| 68 | + - name: source |
| 69 | + required: true |
| 70 | + help: File to upload |
| 71 | + |
| 72 | + flags: |
| 73 | + - long: --user |
| 74 | + short: -u |
| 75 | + arg: user |
| 76 | + help: Username to use for logging in |
| 77 | + required: true |
| 78 | + - long: --password |
| 79 | + short: -p |
| 80 | + arg: password |
| 81 | + help: Password to use for logging in |
| 82 | +``` |
| 83 | +
|
| 84 | +## `settings.yml` |
| 85 | + |
| 86 | +```yaml |
| 87 | +# Display various usage elements in color by providing the name of the color |
| 88 | +# function. The value for each property is a name of a function that is |
| 89 | +# available in your script, for example: `green` or `bold`. |
| 90 | +# You can run `bashly add colors` to add a standard colors library. |
| 91 | +# This option cannot be set via environment variables. |
| 92 | +usage_colors: |
| 93 | + caption: bold |
| 94 | + command: green |
| 95 | + arg: blue |
| 96 | + flag: magenta |
| 97 | + environment_variable: cyan |
| 98 | + |
| 99 | +``` |
| 100 | + |
| 101 | + |
| 102 | +## Generated script output |
| 103 | + |
| 104 | +### `$ ./cli` |
| 105 | + |
| 106 | +```shell |
| 107 | +cli - Sample application |
| 108 | + |
| 109 | +Usage: |
| 110 | + cli COMMAND |
| 111 | + cli [COMMAND] --help | -h |
| 112 | + cli --version | -v |
| 113 | + |
| 114 | +Commands: |
| 115 | + download Download a file |
| 116 | + upload Upload a file |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | +``` |
| 121 | + |
| 122 | +### `$ ./cli -h` |
| 123 | + |
| 124 | +```shell |
| 125 | +cli - Sample application |
| 126 | + |
| 127 | +Usage: |
| 128 | + cli COMMAND |
| 129 | + cli [COMMAND] --help | -h |
| 130 | + cli --version | -v |
| 131 | + |
| 132 | +Commands: |
| 133 | + download Download a file |
| 134 | + upload Upload a file |
| 135 | + |
| 136 | +Options: |
| 137 | + --help, -h |
| 138 | + Show this help |
| 139 | + |
| 140 | + --version, -v |
| 141 | + Show version number |
| 142 | + |
| 143 | +Environment Variables: |
| 144 | + API_KEY |
| 145 | + Set your API key |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | +``` |
| 150 | + |
| 151 | +### `$ ./cli download -h` |
| 152 | + |
| 153 | +```shell |
| 154 | +cli download - Download a file |
| 155 | + |
| 156 | +Alias: d |
| 157 | + |
| 158 | +Usage: |
| 159 | + cli download SOURCE [TARGET] [OPTIONS] |
| 160 | + cli download --help | -h |
| 161 | + |
| 162 | +Options: |
| 163 | + --help, -h |
| 164 | + Show this help |
| 165 | + |
| 166 | + --force, -f |
| 167 | + Overwrite existing files |
| 168 | + |
| 169 | +Arguments: |
| 170 | + SOURCE |
| 171 | + URL to download from |
| 172 | + |
| 173 | + TARGET |
| 174 | + Target filename (default: same as source) |
| 175 | + |
| 176 | +Environment Variables: |
| 177 | + DEFAULT_TARGET_LOCATION |
| 178 | + Set the default location to download to |
| 179 | + |
| 180 | +Examples: |
| 181 | + cli download example.com |
| 182 | + cli download example.com ./output -f |
| 183 | + |
| 184 | + |
| 185 | + |
| 186 | +``` |
| 187 | + |
| 188 | + |
| 189 | + |
0 commit comments