Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add flag and label completion for bazel commands (#4584)
Inspired by #373 with a re-write + simplication + improvement of the completion logic from the original. To enable bash completion: ``` $ brew install bash-completion $ aspect completion bash > $(brew --prefix)/etc/bash_completion.d/aspect # add to your .bash_profile: if [[ -r "$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh" ]]; then . "$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh" echo "bash completion loaded" fi ``` See https://tecadmin.net/enable-bash-completion-on-macos/ for more info. Demos: ``` $ aspect <tab><tab> analyze-profile (Analyze build profile data) info (Display runtime info about the bazel server) aquery (Query the action graph) init (Create a new Bazel workspace) build (Build the specified targets) license (Prints the license of this software.) canonicalize-flags (Present a list of bazel options in a canonical form) lint (Run configured linters over the dependency graph.) clean (Remove the output tree) outputs (Print paths to declared output files) completion (Generate the autocompletion script for the specified shell) print (Print syntax elements from BUILD files) config (Displays details of configurations.) query (Query the dependency graph, ignoring configuration flags) configure (Auto-configure Bazel by updating BUILD files) run (Build a single target and run it with the given arguments) coverage (Same as 'test', but also generates a code coverage report.) shutdown (Stop the bazel server) cquery (Query the dependency graph, honoring configuration flags) support (Interactive, human-escalated support for Bazel problems) docs (Open documentation in the browser) test (Build the specified targets and run all test targets among them) fetch (Fetch external repositories that are prerequisites to the targets) version (Print the versions of Aspect CLI and Bazel) help ``` ``` $ aspect test <tab><tab> :test :test2 foo foo/bar foo/fum/bar ``` ``` $ aspect test foo<tab><tab> foo foo/bar foo/fum/bar foo:foo foo:fum/test foo:test foo:test2 ``` ``` $ aspect test foo/<tab><tab> foo/bar foo/fum/bar ``` ``` $ aspect test //foo<tab><tab> //foo //foo/bar //foo/fum/bar //foo:foo //foo:fum/test //foo:test //foo:test2 ``` ``` $ aspect test //foo/<tab><tab> //foo/bar //foo/fum/bar ``` ``` $ aspect test @//foo<tab><tab> @//foo @//foo/bar @//foo/fum/bar @//foo:foo @//foo:fum/test @//foo:test @//foo:test2 ``` ``` $ aspect test @//foo/<tab><tab> @//foo/bar @//foo/fum/bar ``` ``` $ aspect test @@//foo<tab><tab> @@//foo @@//foo/bar @@//foo/fum/bar @@//foo:foo @@//foo:fum/test @@//foo:test @@//foo:test2 ``` ``` $ aspect test @@//foo/<tab><tab> @@//foo/bar @@//foo/fum/bar ``` ``` $ cd foo $ aspect test <tab><tab> :foo :fum/test :test :test2 bar fum/bar ``` GitOrigin-RevId: 4044b8d8bb34dfad160cb1d4728bf13d10cb3b9c
- Loading branch information