Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham
	autolearn_force=no version=3.4.1
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:reply-to:to:from:subject:organization:message-id
         :date:user-agent:mime-version:content-transfer-encoding;
        bh=OOm8pf2xw8zWi0K/2V91f5cWKqHpCZ1DCV9+nn49+A0=;
        b=NVT3NtvjrIohu+QVa7xDOX25OP9mDhfgrhtXw4djhrX4nGGq3iFDjNm9teoKxIaDTR
         265Ir7CybkmOHd7ZjbVYLAPVkkHKOOC96//DL728wU6XwgMScDWJvdX5DVVc2x+rHfxb
         tvQJIuzaRkgek+a1u2IUVTad6iBzejsGJX9qZlXZyq2OHqJlREu0Dckhi5RfsQj1vx6P
         gdLsItzo315yLd0geo4VligNpC8Angs1nwCa55hMZRcjVy9RhiomzObRTCgMYCkrjbez
         qEHurTYjAkJ4zX3cDIV4AAWcf6w+pGLIG0o2WB2tL/DwHaiFzt6E0yQEnsHLiwq16LRc
         89PQ==
X-Gm-Message-State: AOPr4FV10hFcOGkUVMWpxI7GBglYtxT5g6ZbIErqYrRWsMU5wq7xfSApnGmwTDCGDdw0CMkZ
X-Received: by 10.28.12.8 with SMTP id 8mr11100504wmm.6.1462798516504;
        Mon, 09 May 2016 05:55:16 -0700 (PDT)
Reply-To: Marko Myllynen <myllynen@redhat.com>
To: zsh-workers@zsh.org
From: Marko Myllynen <myllynen@redhat.com>
Subject: [PATCH] zsh localedef completion
Organization: Red Hat
Message-ID: <573088B3.3090709@redhat.com>
Date: Mon, 9 May 2016 15:55:15 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.7.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Seq: zsh-workers 38442

Hi,

Below is zsh completions for the localedef(1) command, I've tested this
on RHEL 7 against the glibc provided localedef command. Otherwise it
works nicely but I'm a bit wondering two things here:

$ localedef -Afoo -<TAB>

offers --alias-file (unexpected to me) alongside the others but

$ localedef --alias-file=foo -<TAB>

does not offer -A (IMHO expected).

$ localedef -c<TAB>

offers also V/? although I hoped them to get excluded in that case.

Anyway, I don't think neither of these are critical issues so I think
this would be already worth merging as-is but if you happen to know the
needed tweaks to address those issues all the better.

http://man7.org/linux/man-pages/man1/localedef.1.html

---
 Completion/Unix/Command/_localedef | 54 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 Completion/Unix/Command/_localedef

diff --git a/Completion/Unix/Command/_localedef b/Completion/Unix/Command/_localedef
new file mode 100644
index 0000000..ac4b438
--- /dev/null
+++ b/Completion/Unix/Command/_localedef
@@ -0,0 +1,54 @@
+#compdef localedef
+
+local curcontext="$curcontext" state line expl ret=1
+local exargs="-? --help --usage -V --version"
+typeset -A opt_args
+
+_arguments -A -C -S -s \
+  '(- *)'{-\?,--help}'[display help information]' \
+  '(- *)--usage[display a short usage message]' \
+  '(- *)'{-V,--version}'[print program version]' \
+  "(-A --alias-file= $exargs)"{-A+,--alias-file=}'[specify locale alias file]:alias file:_files' \
+  "($exargs)--prefix=[specify path prefix]:prefix:_files" \
+  "(-c --force $exargs)"{-c,--force}'[force write despite of warnings]' \
+  "(-v --verbose $exargs)"{-v,--verbose}'[display additional information]' \
+  "($exargs)--quiet[suppress messages and warnings]" \
+  - set1 \
+  "(-f --charmap= $exargs)"{-f+,--charmap=}'[specify locale charmap file]:charmap:->charmap' \
+  "(-i --inputfile= $exargs)"{-i+,--inputfile=}'[specify locale definition file]:locale file:_files' \
+  "(-u --repertoire-map= $exargs)"{-u+,--repertoire-map=}'[specify repertoire map file]:repertoire map file:_files' \
+  '*:path:_files' \
+  - set2 \
+  "($exargs)--list-archive[list locales in archive]" \
+  - set3 \
+  "($exargs)--delete-from-archive[delete locale from archive]" \
+  '*:locale:->locale' \
+  - set4 \
+  "($exargs)--add-to-archive[add locale to archive]" \
+  "($exargs)--replace[replace locale in archive]" \
+  "($exargs)--no-archive[use subdir not archive]" \
+  '*:compiled path:_files -/' \
+  && return 0
+
+case "$state" in
+  charmap)
+    if [[ $words[-1] == */* ]]; then
+      _wanted values expl charmap _files && ret=0
+    else
+      typeset -a charmaps
+      charmaps=( ${(f)"$(locale -m)"} )
+      _wanted values expl charmap compadd "$@" \
+        -M 'm:{a-zA-Z}={A-Za-z} r:|-=* r:|=*' \
+        -a - charmaps && ret=0
+    fi
+  ;;
+  locale)
+    typeset -a locales
+    local pref=${opt_args[--prefix]}
+    local p=${pref:+--prefix}
+    locales=( ${(f)"$(localedef --list-archive $p $pref)"} )
+    _wanted values expl locale compadd "$@" -a - locales && ret=0
+  ;;
+esac
+
+return ret

Thanks,

-- 
Marko Myllynen

