Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: new completion for augeas
- X-seq: zsh-workers 33198
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: new completion for augeas
- Date: Fri, 19 Sep 2014 13:59:15 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1411127956; bh=qRWp7RJ1moNKXmgYEkraE24P29MtelXC6RCeYR01FJ8=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Subject:MIME-Version:Content-Type:Content-ID:Date:Message-ID; b=zxHlU4gowVLuoKEnT1Ds9ncUglwez9gDcpD3/qNrumkXTWoxogqWwP19xqRxTaelmZSzMvQb2c9YkEGCbgI3CLBOR7X9opi2aVtGJ9Nh3oirCWvcGoi7xd7rnYi13SoYgNdG2ZWpPFoqapcSRXrHQQyL30jSB2bJn/PhnjPrtDg=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
This adds completion for augtool. It could be improved, in particular by
handling the xpath-like expressions.
Oliver
diff --git a/Completion/Unix/Command/_augeas b/Completion/Unix/Command/_augeas
new file mode 100644
index 0000000..dedf8c0
--- /dev/null
+++ b/Completion/Unix/Command/_augeas
@@ -0,0 +1,58 @@
+#compdef augtool
+
+local curcontext="$curcontext" state line expl ret=1
+local -A opt_args
+
+_arguments -C -s \
+ '(-c --typecheck)'{-c,--typecheck}'[perform type checking on lenses]' \
+ '(-b --backup)'{-b,--backup}'[preserve original files with .augsave extension]' \
+ '(-n --new)'{-n,--new}'[leave files untouched but save changes with a .augnew extension]' \
+ '(-r --root)'{-r,--root=}'[specify filesystem root]:root directory:_files -/' \
+ \*{-I+,--include=}'[add directory containing lenses to search path]:directory:_files -/' \
+ '(-f --file *)'{-f+,--file=}'[read commands from specified file]:file:_files' \
+ '(-i --interactive)'{-i,--interactive}'[read commands from the terminal]' \
+ '(-e --echo)'{-e,--echo}'[echo commands read from a file or stdin]' \
+ '(-s --autosave)'{-s,--autosave}'[automatically save at the end of instructions]' \
+ '(-S --nostdinc)'{-S,--nostdinc}'[do not search the builtin default directories for modules]' \
+ '(-L --noload)'{-L,--noload}'[do not load any files into the tree on startup]' \
+ '(-A --noautoload)'{-A,--noautoload}'[do not autoload modules from the search path]' \
+ '--span[load span positions for nodes related to a file]' \
+ '(- *)--version[print version information]' \
+ '(-)'{-h,--help}'[print help information]' \
+ '*:: :->subcommands' && ret=0
+
+[[ -z $state ]] && return ret
+
+if [[ CURRENT -eq 1 || $words[1] == help ]]; then
+ local -a subcmds
+ subcmds=( ${${${(f)"$(_call_program subcommands augtool help 2>/dev/null)"}[2,-2]## #}// #- /:} )
+ _describe -t subcommands "augtool command" subcmds && ret=0
+ return ret
+fi
+
+_tags paths
+while _tags; do
+ if _requested paths; then
+ local subcmd="$words[1]"
+ curcontext="${curcontext%:*}-${subcmd}:"
+ if compset -P '/files/'; then
+ _all_labels paths expl path _path_files -W / && ret=0
+ elif compset -P '/augeas/'; then
+ compset -P '*/'
+ local files
+ files=( ${${(f)"$(_call_program path augtool ls ${words[CURRENT]%/*} 2>/dev/null)"}% = *} )
+ while _next_label paths expl path; do
+ compadd "$expl[@]" -- ${files:#*/} && ret=0
+ compadd "$expl[@]" -S '' -- ${(M)files:#*/} && ret=0
+ done
+ else
+ local -a suf
+ suf=(-S '')
+ compset -S '/*' || suf=( -S / )
+ _all_labels paths expl path compadd -P/ "$suf[@]" files augeas && ret=0
+ fi
+ fi
+ (( ret )) || break
+done
+
+return ret
Messages sorted by:
Reverse Date,
Date,
Thread,
Author