summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorscheibelp <scheibel1@llnl.gov>2017-11-06 11:03:36 -0800
committerGitHub <noreply@github.com>2017-11-06 11:03:36 -0800
commit31c5467f56b8e1a4681978fab44f59595efecbf9 (patch)
tree5a4072b6d706da0f6bbdb7e3737b3b6e52286d24 /lib
parentcd4d26705ed188046d1b9041e63c40e9460a91d7 (diff)
downloadspack-31c5467f56b8e1a4681978fab44f59595efecbf9.tar.gz
spack-31c5467f56b8e1a4681978fab44f59595efecbf9.tar.bz2
spack-31c5467f56b8e1a4681978fab44f59595efecbf9.tar.xz
spack-31c5467f56b8e1a4681978fab44f59595efecbf9.zip
Add back help placeholder for "spack load" (#6127)
Fixes #6126 #3183 removed the print_help function from the "modules" module. This adds it back so that if a user invokes 'spack load foo' without having sourced an environment setup script, they will be prompted to do so. This also improves the placeholder message to tell the user to invoke 'spack' as shell function rather than as an executable.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/common/__init__.py22
-rw-r--r--lib/spack/spack/cmd/load.py4
-rw-r--r--lib/spack/spack/cmd/unload.py4
-rw-r--r--lib/spack/spack/cmd/unuse.py4
-rw-r--r--lib/spack/spack/cmd/use.py4
5 files changed, 30 insertions, 8 deletions
diff --git a/lib/spack/spack/cmd/common/__init__.py b/lib/spack/spack/cmd/common/__init__.py
index 8922701e9f..bb4e45438e 100644
--- a/lib/spack/spack/cmd/common/__init__.py
+++ b/lib/spack/spack/cmd/common/__init__.py
@@ -22,3 +22,25 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
+
+import spack
+from llnl.util import tty
+
+
+def print_module_placeholder_help():
+ """
+ For use by commands to tell user how to activate shell support.
+ """
+ tty.msg("This command requires spack's shell integration.", "",
+ "To initialize spack's shell commands, you must run one of",
+ "the commands below. Choose the right command for your shell.",
+ "", "For bash and zsh:",
+ " . %s/setup-env.sh" % spack.share_path, "",
+ "For csh and tcsh:", " setenv SPACK_ROOT %s" % spack.prefix,
+ " source %s/setup-env.csh" % spack.share_path, "",
+ "This exposes a 'spack' shell function, which you can use like",
+ " $ spack load package-foo", "",
+ "Running the Spack executable directly (for example, invoking",
+ "./bin/spack) will bypass the shell function and print this",
+ "placeholder message, even if you have sourced one of the above",
+ "shell integration scripts.")
diff --git a/lib/spack/spack/cmd/load.py b/lib/spack/spack/cmd/load.py
index cb6f8402aa..61c7003855 100644
--- a/lib/spack/spack/cmd/load.py
+++ b/lib/spack/spack/cmd/load.py
@@ -23,7 +23,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import argparse
-import spack.modules
+from spack.cmd.common import print_module_placeholder_help
description = "add package to environment using `module load`"
section = "environment"
@@ -40,4 +40,4 @@ def setup_parser(subparser):
def load(parser, args):
- spack.modules.print_help()
+ print_module_placeholder_help()
diff --git a/lib/spack/spack/cmd/unload.py b/lib/spack/spack/cmd/unload.py
index 3255a4835e..9820ff52d3 100644
--- a/lib/spack/spack/cmd/unload.py
+++ b/lib/spack/spack/cmd/unload.py
@@ -23,7 +23,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import argparse
-import spack.modules
+from spack.cmd.common import print_module_placeholder_help
description = "remove package from environment using `module unload`"
section = "environment"
@@ -39,4 +39,4 @@ def setup_parser(subparser):
def unload(parser, args):
- spack.modules.print_help()
+ print_module_placeholder_help()
diff --git a/lib/spack/spack/cmd/unuse.py b/lib/spack/spack/cmd/unuse.py
index c07b21e0d4..14ca4227d2 100644
--- a/lib/spack/spack/cmd/unuse.py
+++ b/lib/spack/spack/cmd/unuse.py
@@ -23,7 +23,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import argparse
-import spack.modules
+from spack.cmd.common import print_module_placeholder_help
description = "remove package from environment using dotkit"
section = "environment"
@@ -39,4 +39,4 @@ def setup_parser(subparser):
def unuse(parser, args):
- spack.modules.print_help()
+ print_module_placeholder_help()
diff --git a/lib/spack/spack/cmd/use.py b/lib/spack/spack/cmd/use.py
index 11559fc7ff..956f5c6cbc 100644
--- a/lib/spack/spack/cmd/use.py
+++ b/lib/spack/spack/cmd/use.py
@@ -23,7 +23,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import argparse
-import spack.modules
+from spack.cmd.common import print_module_placeholder_help
description = "add package to environment using dotkit"
section = "environment"
@@ -39,4 +39,4 @@ def setup_parser(subparser):
def use(parser, args):
- spack.modules.print_help()
+ print_module_placeholder_help()