summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorAlec Scott <hi@alecbcs.com>2024-09-27 16:02:37 -0700
committerGitHub <noreply@github.com>2024-09-27 16:02:37 -0700
commit5c8d22c5978f07a67d904890e5a1ea8358615b36 (patch)
tree26d67587e23dd2836fdd1d10ee2a84dca2642406 /var
parent07e964c688eaa7ee19c20b2e5ae08a6de0792b95 (diff)
downloadspack-5c8d22c5978f07a67d904890e5a1ea8358615b36.tar.gz
spack-5c8d22c5978f07a67d904890e5a1ea8358615b36.tar.bz2
spack-5c8d22c5978f07a67d904890e5a1ea8358615b36.tar.xz
spack-5c8d22c5978f07a67d904890e5a1ea8358615b36.zip
Better shell completion support for packages (#44756)
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/fd/package.py16
-rw-r--r--var/spack/repos/builtin/packages/git/package.py12
-rw-r--r--var/spack/repos/builtin/packages/rclone/package.py12
-rw-r--r--var/spack/repos/builtin/packages/restic/package.py16
-rw-r--r--var/spack/repos/builtin/packages/ripgrep/package.py16
5 files changed, 71 insertions, 1 deletions
diff --git a/var/spack/repos/builtin/packages/fd/package.py b/var/spack/repos/builtin/packages/fd/package.py
index 3bfc475c33..3711d53192 100644
--- a/var/spack/repos/builtin/packages/fd/package.py
+++ b/var/spack/repos/builtin/packages/fd/package.py
@@ -24,3 +24,19 @@ class Fd(CargoPackage):
version("7.4.0", sha256="33570ba65e7f8b438746cb92bb9bc4a6030b482a0d50db37c830c4e315877537")
depends_on("rust@1.64:", type="build", when="@9:")
+
+ @run_after("install")
+ def install_completions(self):
+ fd = Executable(self.prefix.bin.fd)
+
+ mkdirp(bash_completion_path(self.prefix))
+ with open(bash_completion_path(self.prefix) / "fd", "w") as file:
+ fd("--gen-completions", "bash", output=file)
+
+ mkdirp(fish_completion_path(self.prefix))
+ with open(fish_completion_path(self.prefix) / "fd.fish", "w") as file:
+ fd("--gen-completions", "fish", output=file)
+
+ mkdirp(zsh_completion_path(self.prefix))
+ with open(zsh_completion_path(self.prefix) / "_fd", "w") as file:
+ fd("--gen-completions", "zsh", output=file)
diff --git a/var/spack/repos/builtin/packages/git/package.py b/var/spack/repos/builtin/packages/git/package.py
index 02c6aa7cd3..7f281682ee 100644
--- a/var/spack/repos/builtin/packages/git/package.py
+++ b/var/spack/repos/builtin/packages/git/package.py
@@ -263,7 +263,17 @@ class Git(AutotoolsPackage):
@run_after("install")
def install_completions(self):
- install_tree("contrib/completion", self.prefix.share)
+ mkdirp(bash_completion_path(self.prefix))
+ install(
+ "contrib/completion/git-completion.bash",
+ join_path(bash_completion_path(self.prefix), "git"),
+ )
+
+ mkdirp(zsh_completion_path(self.prefix))
+ install(
+ "contrib/completion/git-completion.zsh",
+ join_path(zsh_completion_path(self.prefix), "_git"),
+ )
@run_after("install")
def install_manpages(self):
diff --git a/var/spack/repos/builtin/packages/rclone/package.py b/var/spack/repos/builtin/packages/rclone/package.py
index 005e2ebbfb..741dd7293f 100644
--- a/var/spack/repos/builtin/packages/rclone/package.py
+++ b/var/spack/repos/builtin/packages/rclone/package.py
@@ -57,3 +57,15 @@ class Rclone(Package):
def install(self, spec, prefix):
mkdirp(prefix.bin)
install("rclone", prefix.bin)
+
+ @run_after("install")
+ def install_completions(self):
+ rclone = Executable(self.prefix.bin.rclone)
+
+ mkdirp(bash_completion_path(self.prefix))
+ mkdirp(fish_completion_path(self.prefix))
+ mkdirp(zsh_completion_path(self.prefix))
+
+ rclone("genautocomplete", "bash", str(bash_completion_path(self.prefix) / "rclone"))
+ rclone("genautocomplete", "fish", str(fish_completion_path(self.prefix) / "rclone.fish"))
+ rclone("genautocomplete", "zsh", str(zsh_completion_path(self.prefix) / "_rclone"))
diff --git a/var/spack/repos/builtin/packages/restic/package.py b/var/spack/repos/builtin/packages/restic/package.py
index 342d614a04..7e94b05e21 100644
--- a/var/spack/repos/builtin/packages/restic/package.py
+++ b/var/spack/repos/builtin/packages/restic/package.py
@@ -44,3 +44,19 @@ class Restic(Package):
def install(self, spec, prefix):
mkdirp(prefix.bin)
install("restic", prefix.bin)
+
+ @run_after("install")
+ def install_completions(self):
+ restic = Executable(self.prefix.bin.restic)
+
+ mkdirp(bash_completion_path(self.prefix))
+ mkdirp(fish_completion_path(self.prefix))
+ mkdirp(zsh_completion_path(self.prefix))
+
+ restic("generate", "--bash-completion", "restic.bash")
+ restic("generate", "--fish-completion", "restic.fish")
+ restic("generate", "--zsh-completion", "_restic")
+
+ install("restic.bash", bash_completion_path(self.prefix))
+ install("restic.fish", fish_completion_path(self.prefix))
+ install("_restic", zsh_completion_path(self.prefix))
diff --git a/var/spack/repos/builtin/packages/ripgrep/package.py b/var/spack/repos/builtin/packages/ripgrep/package.py
index cfa392714c..ee30a1420d 100644
--- a/var/spack/repos/builtin/packages/ripgrep/package.py
+++ b/var/spack/repos/builtin/packages/ripgrep/package.py
@@ -26,3 +26,19 @@ class Ripgrep(CargoPackage):
version("11.0.2", sha256="0983861279936ada8bc7a6d5d663d590ad34eb44a44c75c2d6ccd0ab33490055")
depends_on("rust@1.72:", type="build", when="@14:")
+
+ @run_after("install")
+ def install_completions(self):
+ rg = Executable(self.prefix.bin.rg)
+
+ mkdirp(bash_completion_path(self.prefix))
+ with open(bash_completion_path(self.prefix) / "rg", "w") as file:
+ rg("--generate", "complete-bash", output=file)
+
+ mkdirp(fish_completion_path(self.prefix))
+ with open(fish_completion_path(self.prefix) / "rg.fish", "w") as file:
+ rg("--generate", "complete-fish", output=file)
+
+ mkdirp(zsh_completion_path(self.prefix))
+ with open(zsh_completion_path(self.prefix) / "_rg", "w") as file:
+ rg("--generate", "complete-zsh", output=file)