Conversation
Add a new `openai tools completion <shell>` command that generates shell completion scripts. This makes the CLI more user-friendly by enabling tab completion for commands, subcommands, and options. Usage: openai tools completion bash # for bash openai tools completion zsh # for zsh openai tools completion fish # for fish openai tools completion powershell # for powershell To install, add the output to your shell's completion configuration. Closes openai#843
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6a81d1bb72
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| _init_completion || return | ||
|
|
||
| local commands="api tools" | ||
| local api_commands="chat.completions.create completions.create embeddings.create images.generate images.edit images.variation audio.transcriptions.create audio.translations.create files.create files.list files.retrieve files.delete files.content models.list models.retrieve models.delete fine_tuning.jobs.create fine_tuning.jobs.list fine_tuning.jobs.retrieve fine_tuning.jobs.cancel fine_tuning.jobs.list_events moderations.create" |
There was a problem hiding this comment.
Remove unregistered API names from completion scripts
The api_commands list includes commands that the CLI parser does not register (embeddings.create, images.variation, files.content, and moderations.create), while the actual image variation command is images.create_variation (src/openai/cli/_api/image.py:46). Because shell completion now suggests these invalid entries, users can tab-complete to commands that immediately fail with argparse “invalid choice,” making the new completion feature unreliable for common API discovery flows.
Useful? React with 👍 / 👎.
|
|
||
| local commands="api tools" | ||
| local api_commands="chat.completions.create completions.create embeddings.create images.generate images.edit images.variation audio.transcriptions.create audio.translations.create files.create files.list files.retrieve files.delete files.content models.list models.retrieve models.delete fine_tuning.jobs.create fine_tuning.jobs.list fine_tuning.jobs.retrieve fine_tuning.jobs.cancel fine_tuning.jobs.list_events moderations.create" | ||
| local tools_commands="migrate grit fine_tunes.prepare_data completion" |
There was a problem hiding this comment.
Stop suggesting migrate/grit under tools namespace
This completion list advertises migrate and grit as openai tools subcommands, but those commands are registered at the top level via migrate.register(subparser) in src/openai/cli/_tools/_main.py:13, not under tools. As a result, tab completion drives users toward openai tools migrate / openai tools grit, which the CLI rejects, and it simultaneously omits completion for the valid top-level forms.
Useful? React with 👍 / 👎.
Summary
openai tools completion <shell>command that generates shell completion scriptsUsage
Test plan
openai tools completion bashand verify output is valid bash completion scriptopenai tools completion zshand verify output is valid zsh completion scriptopenai tools completion fishand verify output is valid fish completion scriptopenai tools completion powershelland verify output is valid PowerShell completion scriptCloses #843