_fossil
692 bytes
1#compdef fossil
2
3function _fossil_get_command_list () {
4 fossil help -a | grep -v "Usage|Common|This is"
5}
6
7function _fossil () {
8 local context state state_descr line
9 typeset -A opt_args
10
11 _arguments \
12 '1: :->command'\
13 '2: :->subcommand'
14
15 case $state in
16 command)
17 local _OUTPUT=$(fossil branch 2>&1 | grep "use --repo")
18 if [[ -z "$_OUTPUT" ]]; then
19 compadd "$(_fossil_get_command_list)"
20 else
21 compadd clone init import help version
22 fi ;;
23 subcommand)
24 case "$words[2]" in
25 help) compadd "$(_fossil_get_command_list)" ;;
26 add) compadd "$(fossil extra)" ;;
27 *) compcall -D ;;
28 esac ;;
29 esac
30}
31
32_fossil "$@"