diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2016-12-25 14:15:58 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-25 14:15:58 -0800 |
commit | c4afaabea9c761237fb39ca5b9ffd762c3090d8c (patch) | |
tree | 2a2eefb7ee0f097dd7deba70dad15bf986b1cc9b | |
parent | 041f96b349b3291cce412a855b9cefe5cdffc76b (diff) | |
download | spack-c4afaabea9c761237fb39ca5b9ffd762c3090d8c.tar.gz spack-c4afaabea9c761237fb39ca5b9ffd762c3090d8c.tar.bz2 spack-c4afaabea9c761237fb39ca5b9ffd762c3090d8c.tar.xz spack-c4afaabea9c761237fb39ca5b9ffd762c3090d8c.zip |
Add argument to `spack spec` to show deptypes. (#2680)
- `-t` | `--types` argument now shows deptypes in `spack spec`
-rw-r--r-- | lib/spack/spack/cmd/spec.py | 4 | ||||
-rw-r--r-- | lib/spack/spack/spec.py | 17 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/spack/spack/cmd/spec.py b/lib/spack/spack/cmd/spec.py index 4dd4474bd4..4ecd4d6e54 100644 --- a/lib/spack/spack/cmd/spec.py +++ b/lib/spack/spack/cmd/spec.py @@ -49,6 +49,9 @@ def setup_parser(subparser): 'installed [+], missing and needed by an installed package [-], ' 'or not installed (no annotation).') subparser.add_argument( + '-t', '--types', action='store_true', default=False, + help='Show dependency types.') + subparser.add_argument( 'specs', nargs=argparse.REMAINDER, help="specs of packages") @@ -59,6 +62,7 @@ def spec(parser, args): 'format': name_fmt + '$@$%@+$+$=', 'hashes': args.long or args.very_long, 'hashlen': None if args.very_long else 7, + 'show_types': args.types, 'install_status': args.install_status} for spec in spack.cmd.parse_specs(args.specs): diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 23212ba72b..8230142d43 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -2595,17 +2595,22 @@ class Spec(object): indent = kwargs.pop('indent', 0) fmt = kwargs.pop('format', '$_$@$%@+$+$=') prefix = kwargs.pop('prefix', None) + show_types = kwargs.pop('show_types', False) deptypes = kwargs.pop('deptypes', ('build', 'link')) check_kwargs(kwargs, self.tree) out = "" - for d, node in self.traverse( + for d, dep_spec in self.traverse_with_deptype( order='pre', cover=cover, depth=True, deptypes=deptypes): + node = dep_spec.spec + if prefix is not None: out += prefix(node) out += " " * indent + if depth: out += "%-4d" % d + if install_status: status = node._install_status() if status is None: @@ -2617,6 +2622,16 @@ class Spec(object): if hashes: out += colorize('@K{%s} ', color=color) % node.dag_hash(hlen) + + if show_types: + out += '[' + if dep_spec.deptypes: + for t in alldeps: + out += ''.join(t[0] if t in dep_spec.deptypes else ' ') + else: + out += ' ' * len(alldeps) + out += '] ' + out += (" " * d) if d > 0: out += "^" |