summaryrefslogtreecommitdiff
path: root/plugins/codeclimate/_codeclimate
diff options
context:
space:
mode:
authorAndy Blyler <andy@blyler.cc>2015-09-01 23:08:41 -0400
committerAndy Blyler <andy@blyler.cc>2015-09-01 23:08:41 -0400
commitb08431ff7431528f0e9dc49ceb199be2226266dc (patch)
treeac30894dd02549b810e2de95319b7454603b6dfb /plugins/codeclimate/_codeclimate
parent0532860c618aabc02d5dab34391b967e8e4c6272 (diff)
downloadzsh-b08431ff7431528f0e9dc49ceb199be2226266dc.tar.gz
zsh-b08431ff7431528f0e9dc49ceb199be2226266dc.tar.bz2
zsh-b08431ff7431528f0e9dc49ceb199be2226266dc.zip
Add codeclimate autocomplete plugin
Diffstat (limited to 'plugins/codeclimate/_codeclimate')
-rw-r--r--plugins/codeclimate/_codeclimate82
1 files changed, 82 insertions, 0 deletions
diff --git a/plugins/codeclimate/_codeclimate b/plugins/codeclimate/_codeclimate
new file mode 100644
index 000000000..fd2536a34
--- /dev/null
+++ b/plugins/codeclimate/_codeclimate
@@ -0,0 +1,82 @@
+#compdef codeclimate
+
+_codeclimate_all_engines() {
+ engines_all=(`codeclimate engines:list | tail -n +2 | gawk '{ print $2 }' | gawk -F: '{ print $1 }'`)
+}
+
+_codeclimate_installed_engines() {
+ _codeclimate_all_engines
+
+ engines_installed=()
+
+ if [ -e .codeclimate.yml ]
+ then
+ for engine in $engines_all
+ do
+ if grep -q $engine ".codeclimate.yml"
+ then
+ engines_installed+=$engine
+ fi
+ done
+ fi
+}
+
+_codeclimate_not_installed_engines() {
+ _codeclimate_all_engines
+
+ engines_not_installed=()
+
+ if [ -e .codeclimate.yml ]
+ then
+ for engine in $engines_all
+ do
+ if ! grep -q $engine ".codeclimate.yml"
+ then
+ engines_not_installed+=$engine
+ fi
+ done
+ fi
+}
+
+local curcontext="$curcontext" state line ret=1
+local expl
+local -a engines_all engines_installed engines_not_installed
+
+_arguments \
+ '1: :->cmds' \
+ '*:: :->args' && ret=0
+
+case $state in
+ cmds)
+ _values "bundle command" \
+ "analyze[Analyze all relevant files in the current working directory]" \
+ "console[Start an interactive session providing access to the classes within the CLI]" \
+ "engines\:disable[Prevents the engine from being used in this project]" \
+ "engines\:enable[This engine will be run the next time your project is analyzed]" \
+ "engines\:install[Compares the list of engines in your .codeclimate.yml file to those that are currently installed, then installs any missing engines]" \
+ "engines\:list[Lists all available engines in the Code Climate Docker Hub]" \
+ "engines\:remove[Removes an engine from your .codeclimate.yml file]" \
+ "help[Displays a list of commands that can be passed to the Code Climate CLI]" \
+ "init[Generates a new .codeclimate.yml file in the current working directory]" \
+ "validate-config[Validates the .codeclimate.yml file in the current working directory]" \
+ "version[Displays the current version of the Code Climate CLI]"
+ ret=0
+ ;;
+ args)
+ case $line[1] in
+ engines:enable)
+ _codeclimate_not_installed_engines
+ _wanted engines_not_installed expl 'not installed engines' compadd -a engines_not_installed ;;
+ engines:disable|engines:remove)
+ _codeclimate_installed_engines
+ _wanted engines_installed expl 'installed engines' compadd -a engines_installed ;;
+ analyze)
+ _arguments \
+ '-f:Output Format:(text json)'
+ ret=0
+ ;;
+ esac
+ ;;
+esac
+
+return ret