kargo icon indicating copy to clipboard operation
kargo copied to clipboard

Tab completion should also look at the Kargo API

Open christianh814 opened this issue 1 year ago • 3 comments

Checklist

  • [x] I've searched the issue queue to verify this is not a duplicate feature request.
  • [x] I've pasted the output of kargo version, if applicable.
  • [x] I've pasted logs, if applicable.

Proposed Feature

When using kargo cli, the tab completion should also look at the API that the CLI auth'ed against. Similar to Kubernetes.

Currently:

$ kargo get projects kargo<TAB>
kargo/             kargo-render.yaml 

^ These are local files.

Where as in Kubernetes

$ kubectl get namespaces kargo<tab>
kargo       kargo-demo

^ Those are namespaces (what I actually want)

It would be nice if I could get this.

$ kargo get projects kargo<tab>
kargo-demo

^ tabs out to just show the current projects.

All subcommands should follow this.

Motivation

Make it act more like Kubernetes and other CLI tools.

Suggested Implementation

A good place to look is the kubectl code. Not sure what's involved

christianh814 avatar Apr 17 '24 18:04 christianh814

@christianh814 I've wanted this as well. Thanks for opening the issue.

@hiddeco or @jessesuen in case you know what's involved. I do not.

This definitely won't get into v0.6.0.

krancour avatar Apr 18 '24 00:04 krancour

This is done through "dynamic completion" in Cobra (https://github.com/spf13/cobra/blob/v1.6.x/shell_completions.md#dynamic-completion-of-nouns).

hiddeco avatar Apr 18 '24 07:04 hiddeco

@hiddeco tried that just now to satisfy my own curiosity and wasn't able to get it working. Maybe when time permits, you can show me what I am doing wrong.

krancour avatar Apr 18 '24 14:04 krancour