From 4da59d6230a89f6bb67d36435ecf9908b21f6ed0 Mon Sep 17 00:00:00 2001 From: jlxip Date: Fri, 25 Nov 2022 10:30:46 +0100 Subject: [PATCH] First attempt at bash and zsh completions --- completions/bash | 41 +++++++++++++++++++++++++++++++++++++++++ completions/zsh | 28 ++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100755 completions/bash create mode 100755 completions/zsh diff --git a/completions/bash b/completions/bash new file mode 100755 index 0000000..e420f9b --- /dev/null +++ b/completions/bash @@ -0,0 +1,41 @@ +#!/bin/bash -eu + +# This is a bash completion script for iris +# It should be copied to /usr/share/bash-completion/completions/iris + +_iris_module() { + local cur prev OPTS + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + case $prev in + -f | --test-file) + return 0 # File + ;; + esac + + case $cur in + --*) + OPTS="--help + --version + --stats + --interactive + --dump + --test-file + --debug" + ;; + *) + OPTS="-h + -v + -s + -i + -d + -f" + ;; + esac + + COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) +} + +complete -F _iris_module -o bashdefault -o default iris diff --git a/completions/zsh b/completions/zsh new file mode 100755 index 0000000..d0e020f --- /dev/null +++ b/completions/zsh @@ -0,0 +1,28 @@ +#compdef _iris iris + +# This is a zsh completion script for iris +# It should be copied to /usr/share/zsh/functions/Completion/Unix/_iris + +function _iris { + local context state state_descr line + typeset -A opt_args + + _arguments -C \ + "-h[Show help information]" \ + "--help[Show help information]" \ + "-v[Display the current version of Iris]" \ + "--version[Display the current version of Iris]" \ + "-s[Display Iris version and message stats]" \ + "--stats[Display Iris version and message stats]" \ + "-i[Enter interactive mode (default)]" \ + "--interactive[Enter interactive mode (default)]" \ + "-d[Dump entire message corpus out]" \ + "--dump[Dump entire message corpus out]" \ + "-f[Use the specified test file for messages]:f:->f" \ + "--test-file[Use the specified test file for messages]:f:->f" \ + "--debug[Print warnings and debug informtation during use]" + + if [ "$state" = "f" ]; then + _files + fi +}