Skip to content

Commit 6fcaa67

Browse files
authored
Relinquish -v and -h if the user wants them (#44)
1 parent 84c551d commit 6fcaa67

File tree

50 files changed

+465
-168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+465
-168
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ bash function.
163163
### Flag options
164164

165165
The flag's value will be available to you as `${args[--output]}` in your
166-
bash function (regardless of whether the user provided ut with the long or
166+
bash function (regardless of whether the user provided it with the long or
167167
short form).
168168

169169
Option | Description
@@ -174,6 +174,12 @@ short form).
174174
`arg` | If the flag requires an argument, specify its name here.
175175
`required` | Specify if this flag is required.
176176

177+
#### Special handling for -v and -h
178+
179+
The `-v` and `-h` flags will be used as the short options for `--version` and
180+
`--help` respectively **only if you are not using them in any of your own
181+
flags**.
182+
177183
### Environment Variable options
178184

179185
The below configuration generates this environment variable usage text:

Runfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ def examples
3838
"examples/environment-variables/cli",
3939
"examples/git-like/git",
4040
"examples/minimal/download",
41+
"examples/minus-v/cli",
4142
"examples/multiline/multi",
4243
"examples/yaml/yaml",
43-
"spec/fixtures/workspaces/short-flag/rush",
44+
"spec/fixtures/workspaces/short-command-code/rush",
4445
]
4546
end
4647

examples/colors/colorly

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ colorly_usage() {
3333
printf "Usage:\n"
3434
printf " colorly [MESSAGE] [options]\n"
3535
printf " colorly --help | -h\n"
36-
printf " colorly --version\n"
36+
printf " colorly --version | -v\n"
3737
echo
3838

3939
if [[ -n $long_usage ]]; then
@@ -42,7 +42,7 @@ colorly_usage() {
4242
echo " --help, -h"
4343
printf " Show this help\n"
4444
echo
45-
echo " --version"
45+
echo " --version, -v"
4646
printf " Show version number\n"
4747
echo
4848

@@ -104,12 +104,12 @@ cyan_underlined() { printf "\e[4;36m%b\e[0m\n" "$*"; }
104104
parse_requirements() {
105105
# :command.fixed_flag_filter
106106
case "$1" in
107-
--version )
107+
--version | -v )
108108
version_command
109109
exit 1
110110
;;
111111

112-
--help | -h )
112+
--help | -h )
113113
long_usage=yes
114114
colorly_usage
115115
exit 1

examples/command-default/ftp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ftp_usage() {
2020
printf "Usage:\n"
2121
printf " ftp [command] [options]\n"
2222
printf " ftp [command] --help | -h\n"
23-
printf " ftp --version\n"
23+
printf " ftp --version | -v\n"
2424
echo
2525
# :command.usage_commands
2626
printf "Commands:\n"
@@ -34,7 +34,7 @@ ftp_usage() {
3434
echo " --help, -h"
3535
printf " Show this help\n"
3636
echo
37-
echo " --version"
37+
echo " --version, -v"
3838
printf " Show version number\n"
3939
echo
4040

@@ -142,12 +142,12 @@ ftp_download_command() {
142142
parse_requirements() {
143143
# :command.fixed_flag_filter
144144
case "$1" in
145-
--version )
145+
--version | -v )
146146
version_command
147147
exit 1
148148
;;
149149

150-
--help | -h )
150+
--help | -h )
151151
long_usage=yes
152152
ftp_usage
153153
exit 1
@@ -215,12 +215,12 @@ parse_requirements() {
215215
ftp_upload_parse_requirements() {
216216
# :command.fixed_flag_filter
217217
case "$1" in
218-
--version )
218+
--version | -v )
219219
version_command
220220
exit 1
221221
;;
222222

223-
--help | -h )
223+
--help | -h )
224224
long_usage=yes
225225
ftp_upload_usage
226226
exit 1
@@ -269,12 +269,12 @@ ftp_upload_parse_requirements() {
269269
ftp_download_parse_requirements() {
270270
# :command.fixed_flag_filter
271271
case "$1" in
272-
--version )
272+
--version | -v )
273273
version_command
274274
exit 1
275275
;;
276276

277-
--help | -h )
277+
--help | -h )
278278
long_usage=yes
279279
ftp_download_usage
280280
exit 1

examples/command-groups/ftp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ftp_usage() {
2020
printf "Usage:\n"
2121
printf " ftp [command] [options]\n"
2222
printf " ftp [command] --help | -h\n"
23-
printf " ftp --version\n"
23+
printf " ftp --version | -v\n"
2424
echo
2525
# :command.usage_commands
2626
printf "File Commands:\n"
@@ -37,7 +37,7 @@ ftp_usage() {
3737
echo " --help, -h"
3838
printf " Show this help\n"
3939
echo
40-
echo " --version"
40+
echo " --version, -v"
4141
printf " Show version number\n"
4242
echo
4343

@@ -207,12 +207,12 @@ ftp_logout_command() {
207207
parse_requirements() {
208208
# :command.fixed_flag_filter
209209
case "$1" in
210-
--version )
210+
--version | -v )
211211
version_command
212212
exit 1
213213
;;
214214

215-
--help | -h )
215+
--help | -h )
216216
long_usage=yes
217217
ftp_usage
218218
exit 1
@@ -288,12 +288,12 @@ parse_requirements() {
288288
ftp_download_parse_requirements() {
289289
# :command.fixed_flag_filter
290290
case "$1" in
291-
--version )
291+
--version | -v )
292292
version_command
293293
exit 1
294294
;;
295295

296-
--help | -h )
296+
--help | -h )
297297
long_usage=yes
298298
ftp_download_usage
299299
exit 1
@@ -342,12 +342,12 @@ ftp_download_parse_requirements() {
342342
ftp_upload_parse_requirements() {
343343
# :command.fixed_flag_filter
344344
case "$1" in
345-
--version )
345+
--version | -v )
346346
version_command
347347
exit 1
348348
;;
349349

350-
--help | -h )
350+
--help | -h )
351351
long_usage=yes
352352
ftp_upload_usage
353353
exit 1
@@ -396,12 +396,12 @@ ftp_upload_parse_requirements() {
396396
ftp_login_parse_requirements() {
397397
# :command.fixed_flag_filter
398398
case "$1" in
399-
--version )
399+
--version | -v )
400400
version_command
401401
exit 1
402402
;;
403403

404-
--help | -h )
404+
--help | -h )
405405
long_usage=yes
406406
ftp_login_usage
407407
exit 1
@@ -438,12 +438,12 @@ ftp_login_parse_requirements() {
438438
ftp_logout_parse_requirements() {
439439
# :command.fixed_flag_filter
440440
case "$1" in
441-
--version )
441+
--version | -v )
442442
version_command
443443
exit 1
444444
;;
445445

446-
--help | -h )
446+
--help | -h )
447447
long_usage=yes
448448
ftp_logout_usage
449449
exit 1

examples/commands-nested/cli

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cli_usage() {
2020
printf "Usage:\n"
2121
printf " cli [command] [options]\n"
2222
printf " cli [command] --help | -h\n"
23-
printf " cli --version\n"
23+
printf " cli --version | -v\n"
2424
echo
2525
# :command.usage_commands
2626
printf "Commands:\n"
@@ -34,7 +34,7 @@ cli_usage() {
3434
echo " --help, -h"
3535
printf " Show this help\n"
3636
echo
37-
echo " --version"
37+
echo " --version, -v"
3838
printf " Show version number\n"
3939
echo
4040

@@ -291,12 +291,12 @@ cli_file_edit_command() {
291291
parse_requirements() {
292292
# :command.fixed_flag_filter
293293
case "$1" in
294-
--version )
294+
--version | -v )
295295
version_command
296296
exit 1
297297
;;
298298

299-
--help | -h )
299+
--help | -h )
300300
long_usage=yes
301301
cli_usage
302302
exit 1
@@ -358,12 +358,12 @@ parse_requirements() {
358358
cli_dir_parse_requirements() {
359359
# :command.fixed_flag_filter
360360
case "$1" in
361-
--version )
361+
--version | -v )
362362
version_command
363363
exit 1
364364
;;
365365

366-
--help | -h )
366+
--help | -h )
367367
long_usage=yes
368368
cli_dir_usage
369369
exit 1
@@ -425,12 +425,12 @@ cli_dir_parse_requirements() {
425425
cli_dir_list_parse_requirements() {
426426
# :command.fixed_flag_filter
427427
case "$1" in
428-
--version )
428+
--version | -v )
429429
version_command
430430
exit 1
431431
;;
432432

433-
--help | -h )
433+
--help | -h )
434434
long_usage=yes
435435
cli_dir_list_usage
436436
exit 1
@@ -479,12 +479,12 @@ cli_dir_list_parse_requirements() {
479479
cli_dir_remove_parse_requirements() {
480480
# :command.fixed_flag_filter
481481
case "$1" in
482-
--version )
482+
--version | -v )
483483
version_command
484484
exit 1
485485
;;
486486

487-
--help | -h )
487+
--help | -h )
488488
long_usage=yes
489489
cli_dir_remove_usage
490490
exit 1
@@ -539,12 +539,12 @@ cli_dir_remove_parse_requirements() {
539539
cli_file_parse_requirements() {
540540
# :command.fixed_flag_filter
541541
case "$1" in
542-
--version )
542+
--version | -v )
543543
version_command
544544
exit 1
545545
;;
546546

547-
--help | -h )
547+
--help | -h )
548548
long_usage=yes
549549
cli_file_usage
550550
exit 1
@@ -606,12 +606,12 @@ cli_file_parse_requirements() {
606606
cli_file_show_parse_requirements() {
607607
# :command.fixed_flag_filter
608608
case "$1" in
609-
--version )
609+
--version | -v )
610610
version_command
611611
exit 1
612612
;;
613613

614-
--help | -h )
614+
--help | -h )
615615
long_usage=yes
616616
cli_file_show_usage
617617
exit 1
@@ -660,12 +660,12 @@ cli_file_show_parse_requirements() {
660660
cli_file_edit_parse_requirements() {
661661
# :command.fixed_flag_filter
662662
case "$1" in
663-
--version )
663+
--version | -v )
664664
version_command
665665
exit 1
666666
;;
667667

668-
--help | -h )
668+
--help | -h )
669669
long_usage=yes
670670
cli_file_edit_usage
671671
exit 1

0 commit comments

Comments
 (0)