Skip to content

Allow handing of completion by an external command's shell completion #774

Description

@Wikiwix

We have a wrapper script around terraform and it would be nice to be able to profit from the completion available for the wrapped command.

What we currently do:

arg "<layer>" help="Layer to run"
arg "<command>" var=#true help="Terraform command to run"
complete "command" descriptions=#true run=#"terraform -help 2>&1 | awk '/^  [a-z]/ {cmd=$1; $1=""; sub(/^ +/,""); print cmd":"$0}'"#

It would be nice if the completion could not require awk and support further stuff like terraform plan -o completing to -out.

To demonstrate what would need to happen technically (with fish as an example):

arg "<layer>" help="Layer to run"
arg "<command>" var=#true help="Terraform command to run"
complete "command" descriptions=#true run=#"fish -c 'complete -C "terraform {{words[CURRENT]}"'"#
// The `words[CURRENT]` is not really correct, as we need all the words that belong to the `command` arg for this to work properly.
// (I don't know if that is currently possible)

As usage already must be aware of all the completion frameworks it supports, I feel like handing that over would be natural.

I am not sure that the arg var=#true style to model this situation is the best way to support this new functionality. I just chose this to bring the point across.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions