zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh workers <zsh-workers@zsh.org>
Subject: PATCH: gsettings completion
Date: Mon, 01 Aug 2016 22:57:10 +0200	[thread overview]
Message-ID: <17561.1470085030@hydra.kiddle.eu> (raw)

New completion for gsettings.

Oliver

diff --git a/Completion/Unix/Command/_gsettings b/Completion/Unix/Command/_gsettings
new file mode 100644
index 0000000..f47bbc6
--- /dev/null
+++ b/Completion/Unix/Command/_gsettings
@@ -0,0 +1,47 @@
+#compdef gsettings
+
+local curcontext="$curcontext" state line expl ret=1
+local subcmds
+
+_arguments \
+  '(- 1 *)--version[show version information]' \
+  '--schemadir[specify location of schemata]:directory:_directories' \
+  ':command:->subcmds' \
+  '*::args:->subargs' && ret=0
+
+if [[ $state = subargs ]]; then
+  curcontext="${curcontext%:*}-$words[1]:"
+  case $words[1] in
+    help) state=subcmds;;
+    get|range|reset|writable|monitor)
+      _arguments ':schema:->schemata' ':key:->keys'
+    ;;
+    set)
+      _arguments ':schema:->schemata' ':key:->keys' ':value'
+    ;;
+    (list|reset)-(keys|recursively|children)) state=schemata ;;
+    *) _default && ret=0 ;;
+  esac
+fi
+
+case $state in
+  subcmds)
+    subcmds=( ${(L)${${(M)${${(f)"$(_call_program commands $service help)"}[(r)Commands:*,-2]}:#  *}#??}/ ##/:} )
+    _describe -t commands 'command' subcmds -M 'r:?|-=* r:|=*' && ret=0
+    state=''
+  ;;
+  schemata)
+    if compset -P '*:'; then
+      _directories && ret=0
+    else
+      _wanted schemata expl 'schema' compadd -M 'r:|.=* r:|=*' \
+          $(_call_program schemata $service list-schemas) && ret=0
+    fi
+  ;;
+  keys)
+    _wanted keys expl 'key' compadd \
+        $(_call_program keys $service list-keys $words[CURRENT-1]) && ret=0
+  ;;
+esac
+
+return ret


                 reply	other threads:[~2016-08-01 21:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17561.1470085030@hydra.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).