Skip to content
Snippets Groups Projects
Commit 88f57d75 authored by Elizabeth Fischer's avatar Elizabeth Fischer Committed by Todd Gamblin
Browse files

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.
parent 17b13b16
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment