@@ -24,25 +24,27 @@ rush_usage() {
2424 echo
2525 # :command.usage_commands
2626 printf " Repository Commands:\n"
27- echo " add Register a local repository"
28- echo " remove Unregister a local repository"
27+ echo " add Register a local repository"
28+ echo " remove Unregister a local repository"
2929 printf " \nGit Commands:\n"
30- echo " clone Clone a GitHub package repository"
31- echo " pull Git pull one or all repositories"
32- echo " push Git push one or all repositories"
30+ echo " clone Clone a GitHub package repository"
31+ echo " pull Git pull one or all repositories"
32+ echo " push Git push one or all repositories"
3333 printf " \nConfig Commands:\n"
34- echo " config Show or edit the configuration file"
35- echo " default Set a default repository"
34+ echo " config Show or edit the configuration file"
35+ echo " default Set a default repository"
3636 printf " \nPackage Commands:\n"
37- echo " get Install a package (default)"
38- echo " undo Uninstall a package"
39- echo " snatch Install a package from a remote repo"
40- echo " copy Copy a package between local repositories"
41- echo " info Show information about a package"
42- echo " list Show packages in one or all repositories"
43- echo " search Search in package names and info files"
44- echo " edit Edit package files"
45- echo " show Show package files"
37+ echo " get Install a package (default)"
38+ echo " undo Uninstall a package"
39+ echo " snatch Install a package from a remote repo"
40+ echo " copy Copy a package between local repositories"
41+ echo " info Show information about a package"
42+ echo " list Show packages in one or all repositories"
43+ echo " search Search in package names and info files"
44+ echo " edit Edit package files"
45+ echo " show Show package files"
46+ printf " \nInternal Commands:\n"
47+ echo " completions Generate bash completions"
4648 echo
4749
4850 if [[ -n $long_usage ]]; then
@@ -791,6 +793,31 @@ rush_show_usage() {
791793 fi
792794}
793795
796+ # :command.usage
797+ rush_completions_usage () {
798+ if [[ -n $long_usage ]]; then
799+ printf " rush completions - Generate bash completions\n"
800+ echo
801+ else
802+ printf " rush completions - Generate bash completions\n"
803+ echo
804+ fi
805+
806+ printf " Usage:\n"
807+ printf " rush completions\n"
808+ printf " rush completions --help | -h\n"
809+ echo
810+
811+ if [[ -n $long_usage ]]; then
812+ printf " Options:\n"
813+ # :command.usage_fixed_flags
814+ echo " --help, -h"
815+ printf " Show this help\n"
816+ echo
817+
818+ fi
819+ }
820+
794821# :command.inspect_args
795822inspect_args () {
796823 readarray -t sorted_keys < <( printf ' %s\n' " ${! args[@]} " | sort)
@@ -990,6 +1017,41 @@ say() {
9901017 printf " %-20s | %s\n" " $( magenta " $1 " ) " " $( bold " ${*: 2} " ) "
9911018}
9921019
1020+ # :src/lib/send_completions.sh
1021+ send_completions () {
1022+ echo $' #!/usr/bin/env bash'
1023+ echo $' '
1024+ echo $' # This bash completions script was generated by'
1025+ echo $' # completely (https://github.com/dannyben/completely)'
1026+ echo $' # Modifying it manually is not recommended'
1027+ echo $' _rush_completions() {'
1028+ echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
1029+ echo $' '
1030+ echo $' case "$COMP_LINE" in'
1031+ echo $' \' rush completions\' *) COMPREPLY=($(compgen -W "--help -h" -- "$cur")) ;;'
1032+ echo $' \' rush default\' *) COMPREPLY=($(compgen -W "--help -h" -- "$cur")) ;;'
1033+ echo $' \' rush remove\' *) COMPREPLY=($(compgen -W "--help --purge -h -p" -- "$cur")) ;;'
1034+ echo $' \' rush config\' *) COMPREPLY=($(compgen -W "--edit --help -e -h" -- "$cur")) ;;'
1035+ echo $' \' rush snatch\' *) COMPREPLY=($(compgen -W "--help -h" -- "$cur")) ;;'
1036+ echo $' \' rush search\' *) COMPREPLY=($(compgen -W "--help -h" -- "$cur")) ;;'
1037+ echo $' \' rush clone\' *) COMPREPLY=($(compgen -A directory -W "--default --help --ignore --name --shallow --ssh -d -h -i -n -s -w" -- "$cur")) ;;'
1038+ echo $' \' rush pull\' *) COMPREPLY=($(compgen -W "--help -h" -- "$cur")) ;;'
1039+ echo $' \' rush push\' *) COMPREPLY=($(compgen -W "--all --help --message -a -h -m" -- "$cur")) ;;'
1040+ echo $' \' rush undo\' *) COMPREPLY=($(compgen -W "$(rush list -s) --help -h" -- "$cur")) ;;'
1041+ echo $' \' rush copy\' *) COMPREPLY=($(compgen -W "$(rush list -s) --force --help -f -h" -- "$cur")) ;;'
1042+ echo $' \' rush info\' *) COMPREPLY=($(compgen -W "$(rush list -s) --help -h" -- "$cur")) ;;'
1043+ echo $' \' rush list\' *) COMPREPLY=($(compgen -W "--help --simple -h -s" -- "$cur")) ;;'
1044+ echo $' \' rush edit\' *) COMPREPLY=($(compgen -W "$(rush list -s) --help -h" -- "$cur")) ;;'
1045+ echo $' \' rush show\' *) COMPREPLY=($(compgen -W "$(rush list -s) --help -h" -- "$cur")) ;;'
1046+ echo $' \' rush add\' *) COMPREPLY=($(compgen -A directory -W "--help -h" -- "$cur")) ;;'
1047+ echo $' \' rush get\' *) COMPREPLY=($(compgen -W "$(rush list -s) --clone --help -c -h" -- "$cur")) ;;'
1048+ echo $' \' rush\' *) COMPREPLY=($(compgen -W "$(rush list -s) --help --version -h -v add clone completions config copy default edit get info list pull push remove search show snatch undo" -- "$cur")) ;;'
1049+ echo $' esac'
1050+ echo $' }'
1051+ echo $' '
1052+ echo $' complete -F _rush_completions rush'
1053+ }
1054+
9931055# :src/lib/warn.sh
9941056warn () {
9951057 printf " %-20s | %s\n" " $( red " $1 " ) " " $( red_bold " ${*: 2} " ) "
@@ -1568,6 +1630,12 @@ rush_show_command() {
15681630 fi
15691631}
15701632
1633+ # :command.function
1634+ rush_completions_command () {
1635+ # :src/completions_command.sh
1636+ send_completions
1637+ }
1638+
15711639# :command.parse_requirements
15721640parse_requirements () {
15731641 # :command.fixed_flag_filter
@@ -1705,6 +1773,13 @@ parse_requirements() {
17051773 shift $#
17061774 ;;
17071775
1776+ completions )
1777+ action=" completions"
1778+ shift
1779+ rush_completions_parse_requirements " $@ "
1780+ shift $#
1781+ ;;
1782+
17081783 # :command.command_fallback
17091784 " " )
17101785 rush_usage
@@ -2723,6 +2798,50 @@ rush_show_parse_requirements() {
27232798 # :command.whitelist_filter
27242799}
27252800
2801+ # :command.parse_requirements
2802+ rush_completions_parse_requirements () {
2803+ # :command.fixed_flag_filter
2804+ case " $1 " in
2805+ --version | -v )
2806+ version_command
2807+ exit
2808+ ;;
2809+
2810+ --help | -h )
2811+ long_usage=yes
2812+ rush_completions_usage
2813+ exit 1
2814+ ;;
2815+
2816+ esac
2817+ # :command.environment_variables_filter
2818+ # :command.dependencies_filter
2819+ # :command.command_filter
2820+ action=" completions"
2821+ # :command.required_args_filter
2822+ # :command.required_flags_filter
2823+ # :command.parse_requirements_while
2824+ while [[ $# -gt 0 ]]; do
2825+ key=" $1 "
2826+ case " $key " in
2827+
2828+ -* )
2829+ printf " invalid option: %s\n" " $key "
2830+ exit 1
2831+ ;;
2832+
2833+ * )
2834+ # :command.parse_requirements_case
2835+ printf " invalid argument: %s\n" " $key "
2836+ exit 1
2837+ ;;
2838+
2839+ esac
2840+ done
2841+ # :command.default_assignments
2842+ # :command.whitelist_filter
2843+ }
2844+
27262845# :command.initialize
27272846initialize () {
27282847 version=" 0.6.4"
@@ -2867,6 +2986,14 @@ run() {
28672986 rush_show_command
28682987 fi
28692988
2989+ elif [[ $action == " completions" ]]; then
2990+ if [[ ${args[--help]} ]]; then
2991+ long_usage=yes
2992+ rush_completions_usage
2993+ else
2994+ rush_completions_command
2995+ fi
2996+
28702997 elif [[ $action == " root" ]]; then
28712998 root_command
28722999 fi
0 commit comments