Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ bash function.
### Flag options

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

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

#### Special handling for -v and -h

The `-v` and `-h` flags will be used as the short options for `--version` and
`--help` respectively **only if you are not using them in any of your own
flags**.

### Environment Variable options

The below configuration generates this environment variable usage text:
Expand Down
3 changes: 2 additions & 1 deletion Runfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ def examples
"examples/environment-variables/cli",
"examples/git-like/git",
"examples/minimal/download",
"examples/minus-v/cli",
"examples/multiline/multi",
"examples/yaml/yaml",
"spec/fixtures/workspaces/short-flag/rush",
"spec/fixtures/workspaces/short-command-code/rush",
]
end

Expand Down
8 changes: 4 additions & 4 deletions examples/colors/colorly
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ colorly_usage() {
printf "Usage:\n"
printf " colorly [MESSAGE] [options]\n"
printf " colorly --help | -h\n"
printf " colorly --version\n"
printf " colorly --version | -v\n"
echo

if [[ -n $long_usage ]]; then
Expand All @@ -42,7 +42,7 @@ colorly_usage() {
echo " --help, -h"
printf " Show this help\n"
echo
echo " --version"
echo " --version, -v"
printf " Show version number\n"
echo

Expand Down Expand Up @@ -104,12 +104,12 @@ cyan_underlined() { printf "\e[4;36m%b\e[0m\n" "$*"; }
parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
colorly_usage
exit 1
Expand Down
16 changes: 8 additions & 8 deletions examples/command-default/ftp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ftp_usage() {
printf "Usage:\n"
printf " ftp [command] [options]\n"
printf " ftp [command] --help | -h\n"
printf " ftp --version\n"
printf " ftp --version | -v\n"
echo
# :command.usage_commands
printf "Commands:\n"
Expand All @@ -34,7 +34,7 @@ ftp_usage() {
echo " --help, -h"
printf " Show this help\n"
echo
echo " --version"
echo " --version, -v"
printf " Show version number\n"
echo

Expand Down Expand Up @@ -142,12 +142,12 @@ ftp_download_command() {
parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
ftp_usage
exit 1
Expand Down Expand Up @@ -215,12 +215,12 @@ parse_requirements() {
ftp_upload_parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
ftp_upload_usage
exit 1
Expand Down Expand Up @@ -269,12 +269,12 @@ ftp_upload_parse_requirements() {
ftp_download_parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
ftp_download_usage
exit 1
Expand Down
24 changes: 12 additions & 12 deletions examples/command-groups/ftp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ftp_usage() {
printf "Usage:\n"
printf " ftp [command] [options]\n"
printf " ftp [command] --help | -h\n"
printf " ftp --version\n"
printf " ftp --version | -v\n"
echo
# :command.usage_commands
printf "File Commands:\n"
Expand All @@ -37,7 +37,7 @@ ftp_usage() {
echo " --help, -h"
printf " Show this help\n"
echo
echo " --version"
echo " --version, -v"
printf " Show version number\n"
echo

Expand Down Expand Up @@ -207,12 +207,12 @@ ftp_logout_command() {
parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
ftp_usage
exit 1
Expand Down Expand Up @@ -288,12 +288,12 @@ parse_requirements() {
ftp_download_parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
ftp_download_usage
exit 1
Expand Down Expand Up @@ -342,12 +342,12 @@ ftp_download_parse_requirements() {
ftp_upload_parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
ftp_upload_usage
exit 1
Expand Down Expand Up @@ -396,12 +396,12 @@ ftp_upload_parse_requirements() {
ftp_login_parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
ftp_login_usage
exit 1
Expand Down Expand Up @@ -438,12 +438,12 @@ ftp_login_parse_requirements() {
ftp_logout_parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
ftp_logout_usage
exit 1
Expand Down
32 changes: 16 additions & 16 deletions examples/commands-nested/cli
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cli_usage() {
printf "Usage:\n"
printf " cli [command] [options]\n"
printf " cli [command] --help | -h\n"
printf " cli --version\n"
printf " cli --version | -v\n"
echo
# :command.usage_commands
printf "Commands:\n"
Expand All @@ -34,7 +34,7 @@ cli_usage() {
echo " --help, -h"
printf " Show this help\n"
echo
echo " --version"
echo " --version, -v"
printf " Show version number\n"
echo

Expand Down Expand Up @@ -291,12 +291,12 @@ cli_file_edit_command() {
parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
cli_usage
exit 1
Expand Down Expand Up @@ -358,12 +358,12 @@ parse_requirements() {
cli_dir_parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
cli_dir_usage
exit 1
Expand Down Expand Up @@ -425,12 +425,12 @@ cli_dir_parse_requirements() {
cli_dir_list_parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
cli_dir_list_usage
exit 1
Expand Down Expand Up @@ -479,12 +479,12 @@ cli_dir_list_parse_requirements() {
cli_dir_remove_parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
cli_dir_remove_usage
exit 1
Expand Down Expand Up @@ -539,12 +539,12 @@ cli_dir_remove_parse_requirements() {
cli_file_parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
cli_file_usage
exit 1
Expand Down Expand Up @@ -606,12 +606,12 @@ cli_file_parse_requirements() {
cli_file_show_parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
cli_file_show_usage
exit 1
Expand Down Expand Up @@ -660,12 +660,12 @@ cli_file_show_parse_requirements() {
cli_file_edit_parse_requirements() {
# :command.fixed_flag_filter
case "$1" in
--version )
--version | -v )
version_command
exit 1
;;

--help | -h )
--help | -h )
long_usage=yes
cli_file_edit_usage
exit 1
Expand Down
Loading