From 7df7d5b4f1961083c425c4bfcacc4cf995e6bfb0 Mon Sep 17 00:00:00 2001 From: CGenie Date: Tue, 28 Dec 2021 19:04:45 +0100 Subject: feat(fossil): add completion for `fossil add` (#8564) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/fossil/_fossil | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 plugins/fossil/_fossil (limited to 'plugins/fossil/_fossil') diff --git a/plugins/fossil/_fossil b/plugins/fossil/_fossil new file mode 100644 index 000000000..d2d48bdec --- /dev/null +++ b/plugins/fossil/_fossil @@ -0,0 +1,32 @@ +#compdef fossil + +function _fossil_get_command_list () { + fossil help -a | grep -v "Usage|Common|This is" +} + +function _fossil () { + local context state state_descr line + typeset -A opt_args + + _arguments \ + '1: :->command'\ + '2: :->subcommand' + + case $state in + command) + local _OUTPUT=$(fossil branch 2>&1 | grep "use --repo") + if [[ -z "$_OUTPUT" ]]; then + compadd "$(_fossil_get_command_list)" + else + compadd clone init import help version + fi ;; + subcommand) + case "$words[2]" in + help) compadd "$(_fossil_get_command_list)" ;; + add) compadd "$(fossil extra)" ;; + *) compcall -D ;; + esac ;; + esac +} + +_fossil "$@" -- cgit v1.2.3-70-g09d2