From 88f57d7543a6b08d6b0436cca9649e9dd1eb6b6d Mon Sep 17 00:00:00 2001
From: Elizabeth Fischer <rpf2116@columbia.edu>
Date: Wed, 28 Dec 2016 16:31:18 -0500
Subject: [PATCH] Allow exclusion of packages from `spack module loads` (#2667)

* Allow exclusion of packages from `spack module loads`

* Comment out excluded packages instead of not showing them at all.
---
 lib/spack/spack/cmd/module.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/spack/spack/cmd/module.py b/lib/spack/spack/cmd/module.py
index 31460b3124..5887cbf495 100644
--- a/lib/spack/spack/cmd/module.py
+++ b/lib/spack/spack/cmd/module.py
@@ -90,6 +90,10 @@ def setup_parser(subparser):
         '-p', '--prefix', dest='prefix', default='',
         help='Prepend to module names when issuing module load commands'
     )
+    loads_parser.add_argument(
+        '-x', '--exclude', dest='exclude', action='append', default=[],
+        help="Exclude package from output; may be specified multiple times"
+    )
     arguments.add_common_arguments(
         loads_parser, ['constraint', 'module_type', 'recurse_dependencies']
     )
@@ -136,8 +140,10 @@ def loads(mtype, specs, args):
         'prefix': args.prefix
     }
 
-    prompt_template = '{comment}{command}{prefix}{name}'
+    exclude_set = set(args.exclude)
+    prompt_template = '{comment}{exclude}{command}{prefix}{name}'
     for spec, mod in modules:
+        d['exclude'] = '## ' if spec.name in exclude_set else ''
         d['comment'] = '' if not args.shell else '# {0}\n'.format(
             spec.format())
         d['name'] = mod
-- 
GitLab