]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/codeclimate/_codeclimate
initial
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / codeclimate / _codeclimate
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
41 local curcontext="$curcontext" state line ret=1
42 local expl
43 local -a engines_all engines_installed engines_not_installed
44
45 _arguments \
46   '1: :->cmds' \
47   '*:: :->args' && ret=0
48
49 case $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     ;;
80 esac
81
82 return ret