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
78 changes: 41 additions & 37 deletions examples/catch-all-advanced/cli
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ version_command() {
cli_usage() {
if [[ -n $long_usage ]]; then
printf "cli - Sample application\n"
echo
echo

else
printf "cli - Sample application\n"
echo
echo

fi

printf "Usage:\n"
Expand Down Expand Up @@ -45,10 +47,12 @@ cli_usage() {
cli_download_usage() {
if [[ -n $long_usage ]]; then
printf "cli download - Download a file\n"
echo
echo

else
printf "cli download - Download a file\n"
echo
echo

fi

printf "Shortcut: d\n"
Expand All @@ -72,25 +76,24 @@ cli_download_usage() {
echo
# :command.usage_args
printf "Arguments:\n"

# :argument.usage
echo " SOURCE"
printf " URL to download from\n"
echo

# :argument.usage
echo " TARGET"
printf " Target filename (default: same as source)\n"
echo



echo " AWS PARAMS..."
printf " Additional arguments or flags for AWS CLI\n"
echo

# :command.usage_examples
printf "Examples:\n"

printf " cli download example.com\n"
printf " cli download example.com ./output -f\n"
echo
Expand All @@ -102,10 +105,12 @@ cli_download_usage() {
cli_upload_usage() {
if [[ -n $long_usage ]]; then
printf "cli upload - Upload a file\n"
echo
echo

else
printf "cli upload - Upload a file\n"
echo
echo

fi

printf "Shortcut: u\n"
Expand All @@ -125,7 +130,7 @@ cli_upload_usage() {

# :command.usage_args
printf "Arguments:\n"

echo " FILES..."
printf " Files to upload\n"
echo
Expand Down Expand Up @@ -204,62 +209,62 @@ parse_requirements() {
version_command
exit
;;

--help | -h )
long_usage=yes
cli_usage
exit
;;

esac
# :command.environment_variables_filter
# :command.dependencies_filter
# :command.command_filter
action=$1

case $action in
-* )
;;

download | d )
action="download"
shift
cli_download_parse_requirements "$@"
shift $#
;;
;;

upload | u )
action="upload"
shift
cli_upload_parse_requirements "$@"
shift $#
;;
;;

# :command.command_fallback
* )
cli_usage
exit 1
;;

esac
# :command.required_args_filter
# :command.required_flags_filter
# :command.parse_requirements_while
while [[ $# -gt 0 ]]; do
key="$1"
case "$key" in

-* )
printf "invalid option: %s\n" "$key"
exit 1
;;

* )
# :command.parse_requirements_case
printf "invalid argument: %s\n" "$key"
exit 1
;;

esac
done
# :command.catch_all_filter
Expand All @@ -275,13 +280,13 @@ cli_download_parse_requirements() {
version_command
exit
;;

--help | -h )
long_usage=yes
cli_download_usage
exit
;;

esac
# :command.environment_variables_filter
# :command.dependencies_filter
Expand All @@ -305,13 +310,12 @@ cli_download_parse_requirements() {
args[--force]=1
shift
;;



-* )
other_args+=("$1")
shift
;;

* )
# :command.parse_requirements_case
if [[ ! ${args[source]} ]]; then
Expand All @@ -325,7 +329,7 @@ cli_download_parse_requirements() {
shift
fi
;;

esac
done
# :command.catch_all_filter
Expand All @@ -341,13 +345,13 @@ cli_upload_parse_requirements() {
version_command
exit
;;

--help | -h )
long_usage=yes
cli_upload_usage
exit
;;

esac
# :command.environment_variables_filter
# :command.dependencies_filter
Expand All @@ -359,18 +363,18 @@ cli_upload_parse_requirements() {
while [[ $# -gt 0 ]]; do
key="$1"
case "$key" in

-* )
other_args+=("$1")
shift
;;

* )
# :command.parse_requirements_case
other_args+=("$1")
shift
;;

esac
done
# :command.catch_all_filter
Expand Down Expand Up @@ -417,15 +421,15 @@ run() {
else
cli_download_command
fi

elif [[ $action == "upload" ]]; then
if [[ ${args[--help]} ]]; then
long_usage=yes
cli_upload_usage
else
cli_upload_command
fi

elif [[ $action == "root" ]]; then
root_command
fi
Expand Down
18 changes: 10 additions & 8 deletions examples/catch-all/download
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ version_command() {
download_usage() {
if [[ -n $long_usage ]]; then
printf "download - Catch All Example\n"
echo
echo

else
printf "download - Catch All Example\n"
echo
echo

fi

printf "Usage:\n"
Expand All @@ -43,7 +45,7 @@ download_usage() {

# :command.usage_args
printf "Arguments:\n"

# :argument.usage
echo " MESSAGE"
printf " Message\n"
Expand Down Expand Up @@ -106,13 +108,13 @@ parse_requirements() {
version_command
exit
;;

--help | -h )
long_usage=yes
download_usage
exit
;;

esac
# :command.environment_variables_filter
# :command.dependencies_filter
Expand All @@ -131,12 +133,12 @@ parse_requirements() {
while [[ $# -gt 0 ]]; do
key="$1"
case "$key" in

-* )
other_args+=("$1")
shift
;;

* )
# :command.parse_requirements_case
if [[ ! ${args[message]} ]]; then
Expand All @@ -147,7 +149,7 @@ parse_requirements() {
shift
fi
;;

esac
done
# :command.catch_all_filter
Expand Down
Loading