summaryrefslogtreecommitdiffstatshomepage
path: root/cheat.sh/shell/_cht
blob: e1a4230ce16b7526472e8bb8487181a3f7fa540f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#compdef cht.sh

__CHTSH_LANGS=($(curl -s cheat.sh/:list))
_arguments -C \
  '--help[show this help message and exit]: :->noargs' \
  '--shell[enter shell repl]: :->noargs' \
  '1:Cheat Sheet:->lang' \
  '*::: :->noargs' && return 0

if [[ CURRENT -ge 1 ]]; then
    case $state in
        noargs)
             _message "nothing to complete";;
        lang)
             compadd -X "Cheat Sheets" ${__CHTSH_LANGS[@]};;
        *)
             _message "Unknown state, error in autocomplete";;
    esac

    return
fi