Skip to content

Commit

Permalink
Generate fish shell completion at build time
Browse files Browse the repository at this point in the history
Fish shell completion for bazel previously relied on parsing bazel help
text at run time, leading to latency of multiple seconds for first-time
completion. This change adds a script that instead parses bazel help
text and generates an appropriate fish completion script at build time,
greatly reducing completion latency for the user.

Fixes #12206
Fixes #12207
Fixes #12208
Fixes #12209
Fixes #12210

Closes #12249.

PiperOrigin-RevId: 337468387
  • Loading branch information
akirabaruah authored and copybara-github committed Oct 16, 2020
1 parent 331c7ed commit 20febac
Show file tree
Hide file tree
Showing 5 changed files with 346 additions and 153 deletions.
22 changes: 21 additions & 1 deletion scripts/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,30 @@ filegroup(
name = "srcs",
srcs = glob(["**"]) + [
"//scripts/docs:srcs",
"//scripts/fish:srcs",
"//scripts/packages:srcs",
"//scripts/release:srcs",
"//scripts/zsh_completion:srcs",
],
visibility = ["//:__pkg__"],
)

py_binary(
name = "generate_fish_completion",
srcs = ["generate_fish_completion.py"],
deps = ["//third_party/py/abseil"],
)

genrule(
name = "fish_completion",
outs = ["bazel.fish"],
cmd = " ".join([
"$(location :generate_fish_completion)",
"--bazel=$(location //src:bazel)",
"--output=$@",
]),
tools = [
":generate_fish_completion",
"//src:bazel",
],
visibility = ["//scripts/packages:__subpackages__"],
)
9 changes: 0 additions & 9 deletions scripts/fish/BUILD

This file was deleted.

5 changes: 3 additions & 2 deletions scripts/fish/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# fish completions

To enable bazel completions, copy //scripts/fish/completions/bazel.fish to
~/.config/fish/completions/bazel.fish.
To enable bazel completions, run `bazel build //scripts:fish_completion` and
copy the resulting script from `bazel-bin/scripts/bazel.fish` to
`~/.config/fish/completions/bazel.fish`.
141 changes: 0 additions & 141 deletions scripts/fish/completions/bazel.fish

This file was deleted.

Loading

0 comments on commit 20febac

Please sign in to comment.