Skip to content

[Feature]: Add dynamic shell completion for flag values (enums) #339

Description

@lockwobr

Prerequisites

  • I searched existing issues

Feature Summary

Shell completion currently works for command names and flag names, but not for flag values. When a user types aicr recipe --intent <TAB>, nothing is suggested. Many flags have a known set of valid values that could be completed automatically.

Problem/Use Case

Add ShellComplete callbacks to flags with known value sets using urfave/cli v3's per-flag completion support.

Flags to complete

Command Flag Completable Values
recipe --intent training, inference, etc.
recipe --service eks, aks, gke, etc.
recipe --accelerator / --gpu h100, a100, b200, etc.
recipe --os ubuntu, rhel, etc.
recipe --platform kubeflow, slurm, etc.
recipe, snapshot, validate --format / -t yaml, json
bundle --deployer helm, argocd, etc.
bundle-verify --min-trust-level Known trust level values
bundle-verify --format yaml, json, text, etc.

Proposed Solution

Implementation approach

urfave/cli v3 supports a ShellComplete callback on each flag:

&cli.StringFlag{
    Name:  "intent",
    Usage: "deployment intent",
    ShellComplete: func(ctx context.Context, cmd *cli.Command) {
        for _, v := range []string{"training", "inference"} {
            fmt.Println(v)
        }
    },

The valid values should come from existing constants or registry data where possible, not hardcoded strings in the CLI layer. This keeps the completion values in sync with what the tool actually accepts.

Source of truth for values

Investigate where each set of values is currently defined:

  • Intent, service, accelerator, OS, platform values may live in recipes/ or pkg/recipe/
  • Deployer values may live in pkg/bundler/
  • Format values are likely defined in pkg/cli/helpers.go
  • Trust levels in pkg/evidence/ or pkg/bundler/

If values are already exported as constants/slices, reference them directly. If they're only in YAML (e.g., recipes/registry.yaml), consider whether to extract them to Go constants or read from the registry at completion time.

Files to change

  • pkg/cli/recipe.go — add ShellComplete to intent, service, accelerator, os, platform flags
  • pkg/cli/bundle.go — add ShellComplete to deployer flag
  • pkg/cli/bundle_verify.go — add ShellComplete to min-trust-level, format flags
  • pkg/cli/snapshot.go — add ShellComplete to format flag
  • pkg/cli/validate.go — add ShellComplete to format flag
  • Possibly pkg/cli/helpers.go — shared completion helper if multiple flags share the same pattern

Notes

  • No changes to pkg/cli/root.go needed — EnableShellCompletion is already true
  • The commandLister function on the root command handles command-level completion; this issue is about flag-value completion only
  • File path flags (--recipe, --snapshot, --output) get default filesystem completion from the shell itself, so no custom completer is needed for those

Success Criteria

  • aicr recipe --intent <TAB> suggests valid intent values
  • aicr recipe --service <TAB> suggests valid service values
  • aicr bundle --deployer <TAB> suggests valid deployer values
  • All other enum flags listed above produce correct suggestions
  • Completion values stay in sync with accepted values (sourced from existing constants/registry, not duplicated strings)
  • Existing command-name and flag-name completion continues to work
  • make test and make lint pass with no regressions
  • Works in bash, zsh, and fish (all shells supported by urfave/cli v3)

Alternatives Considered

No response

Component

CLI (aicr)

Priority

Nice to have

Compatibility / Breaking Changes

No response

Operational Considerations

No response

Are you willing to contribute?

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions