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.
This commit is contained in:
		 Elizabeth Fischer
					Elizabeth Fischer
				
			
				
					committed by
					
						 Todd Gamblin
						Todd Gamblin
					
				
			
			
				
	
			
			
			 Todd Gamblin
						Todd Gamblin
					
				
			
						parent
						
							17b13b161b
						
					
				
				
					commit
					88f57d7543
				
			| @@ -90,6 +90,10 @@ def setup_parser(subparser): | |||||||
|         '-p', '--prefix', dest='prefix', default='', |         '-p', '--prefix', dest='prefix', default='', | ||||||
|         help='Prepend to module names when issuing module load commands' |         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( |     arguments.add_common_arguments( | ||||||
|         loads_parser, ['constraint', 'module_type', 'recurse_dependencies'] |         loads_parser, ['constraint', 'module_type', 'recurse_dependencies'] | ||||||
|     ) |     ) | ||||||
| @@ -136,8 +140,10 @@ def loads(mtype, specs, args): | |||||||
|         'prefix': args.prefix |         '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: |     for spec, mod in modules: | ||||||
|  |         d['exclude'] = '## ' if spec.name in exclude_set else '' | ||||||
|         d['comment'] = '' if not args.shell else '# {0}\n'.format( |         d['comment'] = '' if not args.shell else '# {0}\n'.format( | ||||||
|             spec.format()) |             spec.format()) | ||||||
|         d['name'] = mod |         d['name'] = mod | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user