Skip to content

feat(cli): complete enumerated flag values and model IDs - #110

Merged
sergiught merged 1 commit into
mainfrom
feat/flag-completions
Aug 3, 2026
Merged

feat(cli): complete enumerated flag values and model IDs#110
sergiught merged 1 commit into
mainfrom
feat/flag-completions

Conversation

@sergiught

Copy link
Copy Markdown
Owner

📝 Summary

Flags with a closed set of values fell back to filename completion, so pressing Tab offered filesystem paths where only a handful of words are valid:

# before
$ ofga __complete query check --consistency ""
:0                      # ShellCompDirectiveDefault — i.e. complete filenames

# after
HIGHER_CONSISTENCY
MINIMIZE_LATENCY
UNSPECIFIED

Covered: --consistency, --file-format, --on-duplicate, --on-missing, the global --theme, profiles add --auth-method, and the <key> argument of profiles set/profiles unset — which also completes auth_method's values once the key is typed.

model graph and assertions read/assertions test take an optional [model-id] but offered nothing for it, unlike model get. All three now use the same completion.

Two small consolidations rather than new copies: --consistency completion is registered by the shared helper that defines the flag (so any future command offering it gets this for free), and the model-ID completion moves to internal/cli instead of being written a third time.

🏷 Type of change

  • 🐛 Bug fix (non-breaking)
  • ✨ Feature (non-breaking)
  • 💥 Breaking change (users must update)
  • ♻️ Refactor (no functional change)
  • 📚 Docs only
  • 🛠 Build / CI / tooling

✅ How to verify

make check

Or drive the protocol a shell uses:

ofga __complete query check --consistency ""
ofga __complete profiles set auth_method ""

TestEnumeratedFlagsCompleteTheirValues runs each case through cobra's __complete; every one returned only the :0 filename directive before this change.

Note: touches internal/command/profiles/command.go, so it will need a trivial rebase if #109 (profile headers) merges first.

📋 Checklist

  • 🧪 Tests added or updated where it makes sense
  • 📖 Docs updated (README / command --help / examples) if behavior changed — completion only, no help text changes
  • 🏷 PR title follows Conventional Commits
  • 🟢 make check passes locally

Flags with a closed set of values fell back to filename completion, so
pressing Tab after --consistency offered paths instead of the three values it
accepts. The same held for --file-format, --on-duplicate, --on-missing,
--theme, profiles add --auth-method, and the key argument of profiles
set/unset (which now also completes auth_method's values).

`model graph` and `assertions read`/`assertions test` take an optional model
ID but offered nothing for it, unlike `model get`. They now share one
completion, which moves to internal/cli rather than being copied a third
time.

--consistency is registered through the shared helper that defines the flag,
so any future command offering it completes the same way.
@sergiught
sergiught force-pushed the feat/flag-completions branch from 9342aac to 9e14a7a Compare August 3, 2026 07:08
@sergiught
sergiught merged commit ceab261 into main Aug 3, 2026
7 checks passed
@sergiught
sergiught deleted the feat/flag-completions branch August 3, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant