zsh-users
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Phil Pennock <zsh-workers+phil.pennock@spodhuis.org>
Cc: zsh-users@zsh.org
Subject: Re: completion of normal commands after --
Date: Fri, 6 Jan 2023 12:52:02 +0000	[thread overview]
Message-ID: <20230106125202.GJ8411@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <Y7THHxRd/TjDoVpe@fullerene.field.pennock-tech.net>

Phil Pennock wrote on Tue, Jan 03, 2023 at 19:23:59 -0500:
> So you might run:
> % aws-vault exec profile-foo -n my-command its-flags-and-args
> 
> I have it _almost_ working.  I can see it taking parameters for
> aws-vault after the profile name, I can see it switching to _normal
> execution and tab-completing commands from the path.  The problem comes
> with losing tab-completion for my-command's options.
> 
> Eg, I should be able to run:
> % aws-vault exec website -- ls -<TAB>
> and see the tab-completion for the ls(1) command.
> 
> Instead, at present, I can tab-complete the first word after the '--'
> and no further.  (Without the --, it tab-completes aws-vault's options,
> which is unfortunately correct: they'll be stolen).

That's exactly how «svnadmin freeze» works, and its completion handles
this correctly in a similar case, so see if you can crib from it:
<https://github.com/zsh-users/zsh/blob/d23bcf11714063498a9aec17a360af485026fef2/Completion/Unix/Command/_subversion#L317-L334>.

The two test cases in comments there work for me under `zsh -f` in 5.9.
A third case, with the words (-- .) swapped, offers «`arguments' or
`file'», rather than the external command's options.

Cheers,

Daniel

>     (exec)
>       _arguments -s -S -C \
>         '(-d --duration)'{-d,--duration=}'[duration of temporary or assume-role session]:duration' \
>         '(-n --no-session)'{-n,--no-session}'[use master credentials, no STS session]' \
>         '(-t --mfa-token)'{-t,--mfa-token=}'[the MFA token to use]: ' \
>         '(-j --json)'{-j,--json}'[be an AWS credential helper]' \
>         '(-s --server --ec2-server --ecs-server)'{-s,--server,--ec2-server}'[run EC2 metadata server in background for credentials]' \
>         '(-s --server --ec2-server --ecs-server)--ecs-server[run ECS credential server in background for credentials]' \
>         '--region=[the AWS region]:region:_aws_regions' \
>         '--lazy[When using --ecs-server, lazily fetch credentials]' \
>         '--stdout[Print the SSO link to the terminal without automatically opening the browser]' \
>         '1:profile name:_aws_profiles' \
>         '2:: :->wrapped-command' && return
> 
>       case "$state" in
>       (wrapped-command | '') # '' for the '--' scenario
>         shift $CURRENT words
>         CURRENT=1
>         _normal -p $service
>         ;;
>       esac
>       ;;
> 
> Guidance appreciated, and thanks in advance,
> -Phil
> 


      reply	other threads:[~2023-01-06 12:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04  0:23 Phil Pennock
2023-01-06 12:52 ` Daniel Shahaf [this message]

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=20230106125202.GJ8411@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-users@zsh.org \
    --cc=zsh-workers+phil.pennock@spodhuis.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).