summaryrefslogtreecommitdiff
path: root/Completion/Darwin/Command/_plutil
diff options
context:
space:
mode:
authordana <dana@dana.is>2018-01-05 14:26:17 -0600
committerOliver Kiddle <opk@zsh.org>2018-01-06 00:13:51 +0100
commit0f0b602415961aa9ca069c9719a0fbb4bbb9941f (patch)
tree03001cfaf7ed12c26a354a996f52c4920d08cb76 /Completion/Darwin/Command/_plutil
parent0c5f851021b3aacea96d9ca446282b8dab9f260d (diff)
downloadzsh-0f0b602415961aa9ca069c9719a0fbb4bbb9941f.tar.gz
zsh-0f0b602415961aa9ca069c9719a0fbb4bbb9941f.zip
42231: new completion functions for simple utilities belonging to the 'Darwin' and 'Linux' groups.
Diffstat (limited to 'Completion/Darwin/Command/_plutil')
-rw-r--r--Completion/Darwin/Command/_plutil53
1 files changed, 53 insertions, 0 deletions
diff --git a/Completion/Darwin/Command/_plutil b/Completion/Darwin/Command/_plutil
new file mode 100644
index 000000000..8138a5c5e
--- /dev/null
+++ b/Completion/Darwin/Command/_plutil
@@ -0,0 +1,53 @@
+#compdef plutil
+
+local ret=1 k v
+local -a context line state state_descr tmp fmts=( xml1 binary1 json )
+local -A opt_args val_args types=(
+ -bool 'boolean'
+ -data 'base64-encoded data'
+ -date 'date (XML property-list format)'
+ -float '64-bit float'
+ -integer '64-bit integer'
+ -json 'JSON fragment'
+ -xml 'XML property list'
+)
+
+_arguments -s -S : \
+ '(: -)-help[display help information]' \
+ '(-p -r)-s[suppress normal output]' \
+ '*:input file:_files' \
+ - set1 \
+ '-lint[check input for syntax errors]' \
+ - set2 \
+ "(-extract -insert -replace -remove)-convert[convert to specified format]:output format:(${(j< >)fmts})" \
+ "(-convert -insert -replace -remove)-extract[extract value at specified key path from property list]: :->k:output format:(${(j< >)fmts})" \
+ '(-convert -extract -replace -remove)-insert[insert value at specified key path into property list]: :->k: :->t: :->v' \
+ '(-convert -extract -insert -remove)-replace[replace value at specified key path in property list]: :->k: :->t: :->v' \
+ '(-convert -extract -insert -replace)-remove[remove value at specified key path from property list]: :->k' \
+ '(-o -extract -insert -replace -remove)-e[specify output file extension]:output file extension' \
+ '(-e -extract -insert -replace -remove)-o[specify output file]:output file:_files' \
+ '(-r -s)-p[pretty-print property list]' \
+ '(-p -s)-r[pretty-print JSON]' \
+&& ret=0
+
+case $state in
+ k) _message 'key path' && ret=0 ;;
+ t)
+ tmp=()
+ for k v in ${(kv)types}; do
+ tmp+=( "${k}[${v}]" )
+ done
+ _values 'value type' $tmp && ret=0
+ ;;
+ v)
+ if [[ $words[(CURRENT - 1)] == -bool ]]; then
+ _values $types[-bool] YES NO true false && ret=0
+ elif (( $+types[$words[(CURRENT - 1)]] )); then
+ _message $types[$words[(CURRENT - 1)]] && ret=0
+ else
+ _message value && ret=0
+ fi
+ ;;
+esac
+
+return ret