feat(cli): add shell completion for bash (fix #843)#2934
feat(cli): add shell completion for bash (fix #843)#2934haroldfabla2-hue wants to merge 1 commit intoopenai:mainfrom
Conversation
- Added bash completion script for openai CLI - Supports all CLI flags: api_base, api_key, api_type, azure_*, organization, proxy, verbose, version
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bdf13bda24
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| cur="${COMP_WORDS[COMP_CWORD]}" | ||
| prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
|
|
||
| opts="api_base api_key api_type azure_ad_token azure_endpoint help organization proxy verbose version" |
There was a problem hiding this comment.
Emit real CLI flags in completion candidates
The completion list is built from api_base, api_key, etc., but the CLI parser actually accepts hyphenated, prefixed flags like --api-base, --api-key, --azure-endpoint (src/openai/cli/_cli.py, _build_parser). Because Bash completion matches the current token prefix, a common flow like typing openai --a<Tab> yields no matches, and any suggestions that do appear are not valid command-line flags, so the new completion script is effectively broken for top-level options.
Useful? React with 👍 / 👎.
Summary
Added bash shell completion script for the OpenAI CLI.
Changes
helpers/shell-completion.bashwith bash completion supportUsage
To use the completion, source the script:
source helpers/shell-completion.bashOr copy it to your bash completion directory:
This resolves issue #843: Add shell auto completion for different shells.