zsh-workers
 help / color / mirror / code / Atom feed
From: Nikolai Weibull <now@bitwi.se>
To: Zsh Workers <zsh-workers@zsh.org>
Subject: Suggestion for Completion/Unix/Command/_ln
Date: Fri, 19 Aug 2011 13:05:08 +0200	[thread overview]
Message-ID: <CADdV=MteKpg6z8hyFV9-U0tMbrY8jWfG+BsrzX5DCTpkJEz2Tg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 190 bytes --]

Hi!

Here’s a suggestion for Completion/Unix/Command/_ln.

I have, however, not been able to get _pick_variant to work for
zle/files.  Can someone please suggest a way to handle it?

[-- Attachment #2: _ln --]
[-- Type: application/octet-stream, Size: 3135 bytes --]

#compdef ln gln

local curcontext="$curcontext" state line ret=1
local -A opt_args

local -a args
args=(
  '-f[remove existing destination files]'
  '-s[create symbolic links instead of hard links]')

local -a opts

local variant
_pick_variant -r variant gnu=gnu zsh=zsh unix --help
case $variant in
  (gnu)
    opts=(-S)
    args=(
      '(-b --backup)-b[create a backup of each existing destination file]' \
      '(-b --backup)--backup=[create a backup of each existing destination file]::method:((
         none\:"never create backups"
         off\:"never create backups"
         numbered\:"create numbered backup"
         t\:"create numbered backup"
         existing\:"same as numbered if numbered backups exist, otherwise same as simple"
         nil\:"same as numbered if numbered backups exist, otherwise same as simple"
         simple\:"always create simple backups"
         never\:"always create simple backups"))'
      '(-d -F --directory)'{-d,-F,--directory}'[allow the superuser to attempt to hard link directories]'
      '(-f --force)'{-f,--force}'[remove existing destination files]'
      '(-i --interactive)'{-i,--interactive}'[prompt before removing destination files]'
      '(-L --logical)'{-L,--logical}'[create hard links to symbolic link references]'
      '(-n --no-dereference)'{-n,--no-dereference}'[treat destination symbolic link to a directory as if it were a normal file]'
      '(-P --physical)'{-P,--physical}'[create hard links directly to symbolic links]'
      '(-s --symbolic)'{-s,--symbolic}'[create symbolic links instead of hard links]'
      '(-S --suffix)'{-S,--suffix=}'[override default backup suffix]:suffix'
      '(-t --target-directory)'{-t,--target-directory=}'[specify directory in which to create the links]: :_directories'
      '(-T --no-target-directory)'{-T,--no-target-directory}'[treat destination as a normal file]'
      '(-v --verbose)'{-v,--verbose}'[print name of each linked file]'
      '--help[display usage information and exit]'
      '--version[display version information and exit]')
    ;;
  (zsh)
    args+=(
      '-d[attempt to hard link directories]'
      {-h,-n}'[do not dereference destination]'
        '-i[prompt before removing destination files]')
    ;;
  (*)
    case $OSTYPE in
      (darwin*)
        args+=(
          '-F[remove existing destination directories]'
          {-h,-n}'[do not dereference destination]'
          '-i[prompt before removing destination files]'
          '-v[print name of each linked file]')
        ;;
    esac
    ;;
esac

_arguments -s $opts \
  $args \
  ':link target:_files' \
  '*:: :->files' && ret=0

case $state in
  (files)
    if [[ $variant == gnu && -n ${opt_args[(I)-t|--target-directory]} ]]; then
      _wanted files expl 'link target' _files && ret=0
    else
      if (( CURRENT == 2 )); then
        local expl
        _wanted files expl 'additional link target or link name' _files && ret=0
      else
        _alternative \
          'link-targets:additional link target:_files' \
          'target-directories:target directory:_directories' && ret=0
      fi
    fi
    ;;
esac

return ret

             reply	other threads:[~2011-08-19 11:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-19 11:05 Nikolai Weibull [this message]
2011-08-19 20:23 ` Peter Stephenson
2011-08-20  7:38   ` Nikolai Weibull
2011-08-20  7:45     ` Nikolai Weibull

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='CADdV=MteKpg6z8hyFV9-U0tMbrY8jWfG+BsrzX5DCTpkJEz2Tg@mail.gmail.com' \
    --to=now@bitwi.se \
    --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).