b08431ff7431528f0e9dc49ceb199be2226266dc

Author
Andy Blyler <andy@blyler.cc>
Committer
Andy Blyler <andy@blyler.cc>
Date

Message

Add codeclimate autocomplete plugin

Diff

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