_fossil 692 B

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