Added install option to read spec from file (#4611)

This commit is contained in:
becker33 2017-06-27 12:27:16 -07:00 committed by Todd Gamblin
parent 7b0d295a4c
commit b1861b29ef

View File

@ -77,6 +77,9 @@ def setup_parser(subparser):
subparser.add_argument(
'--fake', action='store_true', dest='fake',
help="fake install. just remove prefix and create a fake file")
subparser.add_argument(
'-f', '--file', action='store_true', dest='file',
help="install from file. Read specs to install from .yaml files")
cd_group = subparser.add_mutually_exclusive_group()
arguments.add_common_arguments(cd_group, ['clean', 'dirty'])
@ -320,7 +323,13 @@ def install(parser, args, **kwargs):
})
# Spec from cli
specs = spack.cmd.parse_specs(args.package, concretize=True)
specs = []
if args.file:
for file in args.package:
with open(file, 'r') as f:
specs.append(spack.spec.Spec.from_yaml(f))
else:
specs = spack.cmd.parse_specs(args.package, concretize=True)
if len(specs) == 0:
tty.error('The `spack install` command requires a spec to install.')