summaryrefslogtreecommitdiff
path: root/etc/completions
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-01-07 12:54:23 +0100
committerDaniel Friesel <derf@finalrewind.org>2011-01-07 12:54:23 +0100
commitfa77754423340aec0bebbed729448c18aa457075 (patch)
treeed68828f71a591ad1aab15ef9922889783e89c15 /etc/completions
parent91ce7d274e15d65b4636ed2d6f8181d15097306d (diff)
Add completion for hashl
Diffstat (limited to 'etc/completions')
-rw-r--r--etc/completions/_hashl66
1 files changed, 66 insertions, 0 deletions
diff --git a/etc/completions/_hashl b/etc/completions/_hashl
new file mode 100644
index 0000000..3aa1d1e
--- /dev/null
+++ b/etc/completions/_hashl
@@ -0,0 +1,66 @@
+#compdef hashl
+
+typeset -a arguments
+typeset -A argument_pairs argument_postfix
+typeset arg expl
+typeset -i NORMARG
+
+function _hashl_directory {
+ _files -/
+}
+
+function _hashl_db_file {
+ typeset index=${words[(I)(-d|--database)]}
+ typeset dbfile=${words[$((index+1))]}
+ typeset IFS=$'\n'
+ if [[ ${index} != 0 && -r ${dbfile} ]] {
+ _wanted file expl 'file' \
+ compadd $(hashl -d ${dbfile} list | grep -v '^#' | cut -d ' ' -f 2-)
+ } else {
+ _wanted file expl 'file' \
+ compadd $(hashl list | grep -v '^#' | cut -d ' ' -f 2-)
+ }
+}
+
+function _hashl_action {
+ _wanted action expl 'action' \
+ compadd copy find-known find-new ignore info list list-ignored update
+}
+
+function _hashl_action_args {
+ case ${words[$NORMARG]} in
+ copy|find-known|find-new|ignore)
+ _hashl_directory
+ ;;
+ info)
+ _hashl_db_file
+ ;;
+ *)
+ _message 'no more arguments'
+ ;;
+ esac
+}
+
+argument_pairs=(
+ database d
+ no-progress n
+ read-size s+
+)
+
+argument_postfix=(
+ database '[hashl db]:file:_files'
+ no-progress '[Do not show progress]'
+ read-size '[Change hashed file part]:bytes'
+)
+
+for arg in ${(k)argument_pairs}; {
+ arguments+='(--'${arg}')-'${argument_pairs[$arg]}${argument_postfix[$arg]}
+ arguments+='(-'${argument_pairs[$arg]}[1]')--'${arg}${argument_postfix[$arg]}
+}
+
+arguments+=(
+ ':action:_hashl_action'
+ '*:arguments:_hashl_action_args'
+)
+
+_arguments -n ${arguments}