feat: bench completions#1707
Merged
netchampfaris merged 7 commits intoApr 23, 2026
Merged
Conversation
377bce2 to
1b8015f
Compare
- Collapse `bench completion bash/zsh/install` into one `bench completions` command; interactive by default, non-interactive when any flag is passed - Replace per-command --help subprocess calls with a single frappe Python process that introspects the click group via get_app_groups(), reducing generation time from ~40s (sequential) to ~1-2s - Extract the frappe introspection script to frappe_spec_collector.py so it can be linted, syntax-highlighted, and run directly for debugging - Fall back to parallel BFS of --help subprocesses for older frappe versions - Suppress progress output in non-interactive mode Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
completion.sh used Click's _BENCH_COMPLETE=complete mechanism (removed in Click 8), spawned Python on every keypress, used `cd` as a side effect during completion, and required hardcoded paths that only worked from the bench root. bench completions supersedes it entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… passed Writing to ~/.zshrc without asking is too aggressive. The completion script file itself is safe to write silently, but dotfile modification should always prompt so users know what changed. --yes/-y opts out for scripts and dotfile managers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…exity Sonar flagged _collect_frappe_tree at complexity 20 (limit 15). Extracting the BFS fallback into _collect_frappe_tree_bfs brings both functions well under the threshold with no logic changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Hardcoded paths under /tmp are publicly writable and can be exploited via symlink attacks. TemporaryDirectory creates a private directory with restricted permissions and cleans it up automatically after the test. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
requests 2.32.5 → 2.33.0 (CVE-2026-25645) uv 0.9.30 → 0.11.6 (GHSA-pjjw-68hj-v9mw) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cf76a20 to
96c094d
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Adds tab completion for bash and zsh via a single
bench completionscommand, and removes the legacycompletion.sh.Usage
Run interactively from your frappe-bench directory:
Or non-interactively with flags:
Must be run from inside a frappe-bench directory — the command detects the bench root from the current working directory to include installed apps' commands in the generated script.
Deleted
completion.shThe old
completion.sh(added in 2018) had several problems:completion.shbench completionscaselookup (~1ms)_BENCH_COMPLETE=completewas removed)../env/bin/python)cdside effect during completionls,cut,xargsbench completionsThe core difference:
completion.shdid live Python introspection on every keypress.bench completionsis a code generator — it bakes the full command tree into static bashcasefunctions once. Runtime completion is pure bash, zero Python.How it works
get_app_groups(), emitting all command metadata as JSON. Generation takes ~1-2s regardless of how many commands are installed.--helpsubprocesses for older Frappe versions that don't exposeget_app_groups().casefunctions — tab completion at runtime is zero-Python.