summaryrefslogtreecommitdiff
path: root/plugins/fossil/_fossil
diff options
context:
space:
mode:
authorCGenie <cgenie@pm.me>2021-12-28 19:04:45 +0100
committerGitHub <noreply@github.com>2021-12-28 19:04:45 +0100
commit7df7d5b4f1961083c425c4bfcacc4cf995e6bfb0 (patch)
treef0cd089e5cd6ae3f16f6192441ee12ad4aabc705 /plugins/fossil/_fossil
parent1d6553e631b6b54d3696e093cfe5d3d854d9b684 (diff)
downloadzsh-7df7d5b4f1961083c425c4bfcacc4cf995e6bfb0.tar.gz
zsh-7df7d5b4f1961083c425c4bfcacc4cf995e6bfb0.tar.bz2
zsh-7df7d5b4f1961083c425c4bfcacc4cf995e6bfb0.zip
feat(fossil): add completion for `fossil add` (#8564)
Co-authored-by: Marc Cornellà <hello@mcornella.com>
Diffstat (limited to 'plugins/fossil/_fossil')
-rw-r--r--plugins/fossil/_fossil32
1 files changed, 32 insertions, 0 deletions
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 "$@"