Skip to content

Add dependency-free CLI shell completion#3129

Open
xodn348 wants to merge 1 commit intoopenai:mainfrom
xodn348:fix/843-cli-shell-completion
Open

Add dependency-free CLI shell completion#3129
xodn348 wants to merge 1 commit intoopenai:mainfrom
xodn348:fix/843-cli-shell-completion

Conversation

@xodn348
Copy link
Copy Markdown

@xodn348 xodn348 commented Apr 27, 2026

Fixes #843.

This adds a built-in openai completion <shell> command for bash, zsh, fish, and PowerShell.

The implementation intentionally avoids adding a new dependency. Instead, it reuses the existing argparse command tree to generate completion candidates for:

  • top-level CLI commands
  • api subcommands
  • tools subcommands
  • supported completion shell names

I noticed #1603 also attempted this with argcomplete; this version keeps the package dependency-free and avoids an extra optional install step.

Testing:

PYTHONPATH=src pytest -q tests/test_cli_completion.py
PYTHONPATH=src python -m ruff check src/openai/cli/_cli.py src/openai/cli/_completion.py tests/test_cli_completion.py
PYTHONPATH=src python -m ruff format --check src/openai/cli/_cli.py src/openai/cli/_completion.py tests/test_cli_completion.py
PYTHONPATH=src python -m mypy src/openai/cli/_completion.py tests/test_cli_completion.py
python3 -m py_compile src/openai/cli/_cli.py src/openai/cli/_completion.py

Results: 4 targeted tests passed; ruff passed; mypy passed; py_compile passed.

@xodn348 xodn348 requested a review from a team as a code owner April 27, 2026 21:46
xodn348 added a commit to xodn348/openai-python that referenced this pull request May 7, 2026
Nightly Codex produced a focused contribution for openai#3129.

Constraint: Automated nightly run; keep changes small and reviewable.

Confidence: medium

Scope-risk: narrow

Tested: See uploaded nightly artifacts and workflow logs.

Not-tested: Maintainer CI beyond this workflow.
@xodn348 xodn348 force-pushed the fix/843-cli-shell-completion branch from a5043a9 to 52bd65b Compare May 7, 2026 08:07
Nightly Codex produced a focused contribution for openai#3129.

Constraint: Automated nightly run; keep changes small and reviewable.

Confidence: medium

Scope-risk: narrow

Tested: See uploaded nightly artifacts and workflow logs.

Not-tested: Maintainer CI beyond this workflow.
@xodn348 xodn348 force-pushed the fix/843-cli-shell-completion branch from 52bd65b to 87859d7 Compare May 8, 2026 07:06
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.

Add shell auto completion for different shell, like bash, zsh, fish, powershell

1 participant