_codeclimate
2479 bytes
1#compdef codeclimate
2
3_codeclimate_all_engines() {
4 engines_all=(`codeclimate engines:list | tail -n +2 | gawk '{ print $2 }' | gawk -F: '{ print $1 }'`)
5}
6
7_codeclimate_installed_engines() {
8 _codeclimate_all_engines
9
10 engines_installed=()
11
12 if [ -e .codeclimate.yml ]
13 then
14 for engine in $engines_all
15 do
16 if grep -q $engine ".codeclimate.yml"
17 then
18 engines_installed+=$engine
19 fi
20 done
21 fi
22}
23
24_codeclimate_not_installed_engines() {
25 _codeclimate_all_engines
26
27 engines_not_installed=()
28
29 if [ -e .codeclimate.yml ]
30 then
31 for engine in $engines_all
32 do
33 if ! grep -q $engine ".codeclimate.yml"
34 then
35 engines_not_installed+=$engine
36 fi
37 done
38 fi
39}
40
41local curcontext="$curcontext" state line ret=1
42local expl
43local -a engines_all engines_installed engines_not_installed
44
45_arguments \
46 '1: :->cmds' \
47 '*:: :->args' && ret=0
48
49case $state in
50 cmds)
51 _values "bundle command" \
52 "analyze[Analyze all relevant files in the current working directory]" \
53 "console[Start an interactive session providing access to the classes within the CLI]" \
54 "engines\:disable[Prevents the engine from being used in this project]" \
55 "engines\:enable[This engine will be run the next time your project is analyzed]" \
56 "engines\:install[Compares the list of engines in your .codeclimate.yml file to those that are currently installed, then installs any missing engines]" \
57 "engines\:list[Lists all available engines in the Code Climate Docker Hub]" \
58 "engines\:remove[Removes an engine from your .codeclimate.yml file]" \
59 "help[Displays a list of commands that can be passed to the Code Climate CLI]" \
60 "init[Generates a new .codeclimate.yml file in the current working directory]" \
61 "validate-config[Validates the .codeclimate.yml file in the current working directory]" \
62 "version[Displays the current version of the Code Climate CLI]"
63 ret=0
64 ;;
65 args)
66 case $line[1] in
67 engines:enable)
68 _codeclimate_not_installed_engines
69 _wanted engines_not_installed expl 'not installed engines' compadd -a engines_not_installed ;;
70 engines:disable|engines:remove)
71 _codeclimate_installed_engines
72 _wanted engines_installed expl 'installed engines' compadd -a engines_installed ;;
73 analyze)
74 _arguments \
75 '-f:Output Format:(text json)'
76 ret=0
77 ;;
78 esac
79 ;;
80esac
81
82return ret