summaryrefslogtreecommitdiff
path: root/lib
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 /lib
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 'lib')
-rw-r--r--lib/spack/spack/package.py1
-rw-r--r--lib/spack/spack/package_completions.py48
2 files changed, 49 insertions, 0 deletions
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index c8de3c2158..bf8538032a 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -99,6 +99,7 @@ from spack.package_base import (
install_dependency_symlinks,
on_package_attributes,
)
+from spack.package_completions import *
from spack.spec import InvalidSpecDetected, Spec
from spack.util.executable import *
from spack.util.filesystem import file_command, fix_darwin_install_name, mime_type
diff --git a/lib/spack/spack/package_completions.py b/lib/spack/spack/package_completions.py
new file mode 100644
index 0000000000..b985d77093
--- /dev/null
+++ b/lib/spack/spack/package_completions.py
@@ -0,0 +1,48 @@
+# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from pathlib import Path
+from typing import Union
+
+"""Functions relating to shell autocompletion scripts for packages."""
+
+
+def bash_completion_path(root: Union[str, Path]) -> Path:
+ """
+ Return standard path for bash completion scripts under root.
+
+ Args:
+ root: The prefix root under which to generate the path.
+
+ Returns:
+ Standard path for bash completion scripts under root.
+ """
+ return Path(root) / "share" / "bash-completion" / "completions"
+
+
+def zsh_completion_path(root: Union[str, Path]) -> Path:
+ """
+ Return standard path for zsh completion scripts under root.
+
+ Args:
+ root: The prefix root under which to generate the path.
+
+ Returns:
+ Standard path for zsh completion scripts under root.
+ """
+ return Path(root) / "share" / "zsh" / "site-functions"
+
+
+def fish_completion_path(root: Union[str, Path]) -> Path:
+ """
+ Return standard path for fish completion scripts under root.
+
+ Args:
+ root: The prefix root under which to generate the path.
+
+ Returns:
+ Standard path for fish completion scripts under root.
+ """
+ return Path(root) / "share" / "fish" / "vendor_completions.d"