UNPKG

3.41 kBapplication/x-shView Raw
1###-begin-ng-completion###
2#
3# ng command completion script
4#
5# Installation: ng completion 1>> ~/.bashrc 2>>&1
6# or ng completion 1>> ~/.zshrc 2>>&1
7#
8
9ng_opts='b build completion doc e2e g generate get github-pages:deploy gh-pages:deploy h help i init install lint make-this-awesome new s serve server set t test v version'
10
11build_opts='--aot --base-href --environment --i18n-file --i18n-format --locale --output-path --progress --sourcemap --suppress-sizes --target --vendor-chunk --verbose --watch --watcher -bh -dev -e -o -prod -sm -t -w'
12generate_opts='class component directive enum module pipe route service c cl d e m p r s --help'
13github_pages_deploy_opts='--base-href --environment --gh-token --gh-username --message --skip-build --target --user-page -bh -e -t'
14help_opts='--json --verbose -v'
15init_opts='--dry-run inline-style inline-template --link-cli --mobile --name --prefix --routing --skip-npm --source-dir --style --verbose -d -is -it -lc -n -p -sb -sd -sn -v'
16new_opts='--directory --dry-run inline-style inline-template --link-cli --mobile --prefix --routing --skip-git --skip-npm --source-dir --style --verbose -d -dir -is -it -lc -p -sb -sd -sg -sn -v'
17serve_opts='--aot --environment --hmr --host --i18n-file --i18n-format --live-reload --live-reload-base-url --live-reload-host --live-reload-live-css --live-reload-port --locale --open --port --proxy-config --sourcemap --ssl --ssl-cert --ssl-key --target --watcher -H -e -lr -lrbu -lrh -lrp -o -p -pc -sm -t -w'
18set_opts='--global -g'
19test_opts='--browsers --build --code-coverage --colors --lint --log-level --port --reporters --single-run --sourcemap --watch -cc -l -sm -sr -w'
20
21version_opts='--verbose'
22
23if test ".$(type -t complete 2>/dev/null || true)" = ".builtin"; then
24 _ng_completion() {
25 local cword pword opts
26
27 COMPREPLY=()
28 cword=${COMP_WORDS[COMP_CWORD]}
29 pword=${COMP_WORDS[COMP_CWORD - 1]}
30
31 case ${pword} in
32 ng) opts=$ng_opts ;;
33 b|build) opts=$build_opts ;;
34 g|generate) opts=$generate_opts ;;
35 gh-pages:deploy|github-pages:deploy) opts=$github_pages_deploy_opts ;;
36 h|help|-h|--help) opts=$help_opts ;;
37 init) opts=$init_opts ;;
38 new) opts=$new_opts ;;
39 s|serve|server) opts=$serve_opts ;;
40 set) opts=$set_opts ;;
41 t|test) opts=$test_opts ;;
42 v|version) opts=$version_opts ;;
43 *) opts='' ;;
44 esac
45
46 COMPREPLY=( $(compgen -W '${opts}' -- $cword) )
47
48 return 0
49 }
50
51 complete -o default -F _ng_completion ng
52elif test ".$(type -w compctl 2>/dev/null || true)" = ".compctl: builtin" ; then
53 _ng_completion () {
54 local words cword opts
55 read -Ac words
56 read -cn cword
57 let cword-=1
58
59 case $words[cword] in
60 ng) opts=$ng_opts ;;
61 b|build) opts=$build_opts ;;
62 g|generate) opts=$generate_opts ;;
63 gh-pages:deploy|github-pages:deploy) opts=$github_pages_deploy_opts ;;
64 h|help|-h|--help) opts=$help_opts ;;
65 init) opts=$init_opts ;;
66 new) opts=$new_opts ;;
67 s|serve|server) opts=$serve_opts ;;
68 set) opts=$set_opts ;;
69 t|test) opts=$test_opts ;;
70 v|version) opts=$version_opts ;;
71 *) opts='' ;;
72 esac
73
74 setopt shwordsplit
75 reply=($opts)
76 unset shwordsplit
77 }
78
79 compctl -K _ng_completion ng
80else
81 echo "Shell builtin command 'complete' or 'compctl' is redefined; cannot perform ng completion."
82 return 1
83fi
84
85###-end-ng-completion###