zsh-workers
 help / color / mirror / code / Atom feed
From: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: [PATCH] new completion function for od
Date: Thu, 23 Jan 2014 00:59:03 +0900	[thread overview]
Message-ID: <769D8A10-B6C7-49D7-BF7C-4CBB5980F8A9@kba.biglobe.ne.jp> (raw)


---

This is a new completion function for the od (octal dump) command


 Completion/Unix/Command/_od | 71 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100644 Completion/Unix/Command/_od

diff --git a/Completion/Unix/Command/_od b/Completion/Unix/Command/_od
new file mode 100644
index 0000000..d542597
--- /dev/null
+++ b/Completion/Unix/Command/_od
@@ -0,0 +1,71 @@
+#compdef od
+
+local context state state_descr line args ret=1
+local -A opt_args
+
+args=(
+  '(-A --address-radix)'{-A+,--address-radix=}'[file offset base]:base:((d\:decimal o\:octal x\:hexadecimal n\:none))'
+  '(-j --skip-bytes)'{-j+,--skip-bytes=}'[skip specified bytes]:bytes'
+  '(-N --read-bytes)'{-N+,--read-bytes=}'[dump at most specified bytes]:bytes'
+  '*'{-t+,--format=}'[specify output format]:format string:->format'
+  '(-v --output-duplicates)'{-v,--output-duplicates}'[do not use * to mark line suppression]'
+  '-a[output named characters (-t a)]'
+  '-b[output octal bytes (-t o1)]'
+  '-c[output characters with C-style escape (-t c)]'
+  '-d[output unsigned decimal shorts (-t u2)]'
+  '-f[output single-precision floats (-t fF)]'
+  {-h,-x}'[output hexadecimal shorts (-t x2)]'
+  '-i[output decimal integers (-t dI)]'
+  {-l,-I,-L}'[output decimal longs (-t dL)]'
+  {-o,-B}'[output octal shorts (-t o2)]'
+  '-s[output decimal shorts (-t d2)]'
+  '*:files:_files'
+)
+
+if _pick_variant gnu=GNU unix --version; then
+  # -h -B -I and -L are obsolescent and undocumented
+  args=( ${(R)args:#(|\*)(|\(*\))-[hBIL]*} )
+  args+=(
+    {-S+,--strings=-}'[output strings of at least specfied bytes long]:length'
+    {-w-,--width=-}'[output specified bytes per line]:bytes'
+    '(- : *)--help[display help and exit]'
+    '(- : *)--version[output version information and exit]'
+  )
+else
+  args=( ${(R)args:#(|\*)(|\(*\))--*} )    # remove long options
+  case "$OSTYPE" in
+    (darwin*|freebsd*|dragonfly*|openbsd*)
+      args+=(
+        '-D[output unsigned decimal ints (-t u4)]'
+        {-e,-F}'[output double-precision floats (-t fD)]'
+        {-H,-X}'[output hexadecimal ints (-t x4)]'
+        '-O[output octal ints (-t o4)]'
+      )
+      ;;
+    (*)
+      # POSIX options only
+      args=( ${(M)args:#(|\*)(|\(*\))-[AjNtvbcdosx]*} )
+      ;;
+  esac
+fi
+
+_arguments -s -S : "$args[@]" && return 0
+
+case "$state" in
+  (format)
+    compset -P '*[acCSIL1248FDL]'
+    if compset -P '*[doux]'; then
+      args=( 'C:char' 'S:short' 'I:int' 'L:long' 1 2 4 8 )
+      _describe -t integer-size 'size of integer' args && ret=0
+    elif compset -P '*f'; then
+      args=( 'F:float' 'D:double' 'L:long double' )
+      _describe -t float-size 'size of float' args && ret=0
+    fi
+    args=( 'a:named character' 'c:character (C-style escape)'
+           'd:decimal' 'o:octal' 'u:unsigned decimal'
+           'x:hexadecimal' 'f:floating-point number' )
+    _describe -t type-specifier 'type specifier' args && ret=0
+  ;;
+esac
+
+return ret
-- 
1.8.3.4 (Apple Git-47)



             reply	other threads:[~2014-01-22 16:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-22 15:59 Jun T. [this message]
2014-01-30 14:53 ` Jun T.
2014-01-30 15:54   ` Peter Stephenson

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=769D8A10-B6C7-49D7-BF7C-4CBB5980F8A9@kba.biglobe.ne.jp \
    --to=takimoto-j@kba.biglobe.ne.jp \
    --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).