From: Phil Pennock <zsh-workers+phil.pennock@spodhuis.org>
To: zsh-users@zsh.org
Subject: completion of normal commands after --
Date: Tue, 3 Jan 2023 19:23:59 -0500 [thread overview]
Message-ID: <Y7THHxRd/TjDoVpe@fullerene.field.pennock-tech.net> (raw)
Folks,
I have a command-wrapper, which can end its own options with '--' per
POSIX, and then _after_ that take the command to be run. This is
something I see with a lot of modern devops-style tools.
In this case, the tool is aws-vault; one of the sub-commands is 'exec',
which needs a profile-name and which has flags, which can appear before
or after the profile-name. After the profile-name is the command to be
run, and it's recommended that you use -- before it if the command takes
options of its own, because otherwise the aws-vault _will_ take those as
its own options.
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).
(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
next reply other threads:[~2023-01-04 0:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-04 0:23 Phil Pennock [this message]
2023-01-06 12:52 ` Daniel Shahaf
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=Y7THHxRd/TjDoVpe@fullerene.field.pennock-tech.net \
--to=zsh-workers+phil.pennock@spodhuis.org \
--cc=zsh-users@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).