diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2017-10-06 13:12:40 -0400 |
---|---|---|
committer | scheibelp <scheibel1@llnl.gov> | 2017-11-02 18:45:40 -0700 |
commit | 4511d9d92451356024dfab2c16c849b9156d551d (patch) | |
tree | 6c35989a0454f1ae7b26ddecdbd8efb5f27183ba | |
parent | b7ec870c3bbf3720dd1d37ca3ef6d93dc478a41f (diff) | |
download | spack-4511d9d92451356024dfab2c16c849b9156d551d.tar.gz spack-4511d9d92451356024dfab2c16c849b9156d551d.tar.bz2 spack-4511d9d92451356024dfab2c16c849b9156d551d.tar.xz spack-4511d9d92451356024dfab2c16c849b9156d551d.zip |
extensions: support only showing a subset of information
-rw-r--r-- | lib/spack/spack/cmd/extensions.py | 92 |
1 files changed, 60 insertions, 32 deletions
diff --git a/lib/spack/spack/cmd/extensions.py b/lib/spack/spack/cmd/extensions.py index c3ec76a058..867481cb8b 100644 --- a/lib/spack/spack/cmd/extensions.py +++ b/lib/spack/spack/cmd/extensions.py @@ -50,6 +50,10 @@ def setup_parser(subparser): '-d', '--deps', action='store_const', dest='mode', const='deps', help='show full dependency DAG of extensions') subparser.add_argument( + '-s', '--show', dest='show', metavar='TYPE', type=str, + default='all', + help="one of packages, installed, activated, all") + subparser.add_argument( '-v', '--view', metavar='VIEW', type=str, help="the view to operate on") @@ -62,6 +66,24 @@ def extensions(parser, args): if not args.spec: tty.die("extensions requires a package spec.") + show_packages = False + show_installed = False + show_activated = False + show_all = False + if args.show == 'packages': + show_packages = True + elif args.show == 'installed': + show_installed = True + elif args.show == 'activated': + show_activated = True + elif args.show == 'all': + show_packages = True + show_installed = True + show_activated = True + show_all = True + else: + tty.die('unrecognized show type: %s' % args.show) + # # Checks # @@ -80,40 +102,46 @@ def extensions(parser, args): if not args.mode: args.mode = 'short' - # - # List package names of extensions - extensions = spack.repo.extensions_for(spec) - if not extensions: - tty.msg("%s has no extensions." % spec.cshort_spec) - return - tty.msg(spec.cshort_spec) - tty.msg("%d extensions:" % len(extensions)) - colify(ext.name for ext in extensions) + if show_packages: + # + # List package names of extensions + extensions = spack.repo.extensions_for(spec) + if not extensions: + tty.msg("%s has no extensions." % spec.cshort_spec) + else: + tty.msg(spec.cshort_spec) + tty.msg("%d extensions:" % len(extensions)) + colify(ext.name for ext in extensions) layout = spack.store.extensions if args.view is not None: layout = YamlViewExtensionsLayout(args.view, spack.store.layout) - # - # List specs of installed extensions. - # - installed = [s.spec - for s in spack.store.db.installed_extensions_for(spec)] - - print - if not installed: - tty.msg("None installed.") - tty.msg("%d installed:" % len(installed)) - spack.cmd.find.display_specs(installed, mode=args.mode) - - # - # List specs of activated extensions. - # - activated = layout.extension_map(spec) - print - if not activated: - tty.msg("None activated.") - return - tty.msg("%d currently activated:" % len(activated)) - spack.cmd.find.display_specs( - activated.values(), mode=args.mode, long=args.long) + if show_installed: + # + # List specs of installed extensions. + # + installed = [s.spec + for s in spack.store.db.installed_extensions_for(spec)] + + if show_all: + print + if not installed: + tty.msg("None installed.") + else: + tty.msg("%d installed:" % len(installed)) + spack.cmd.find.display_specs(installed, mode=args.mode) + + if show_activated: + # + # List specs of activated extensions. + # + activated = layout.extension_map(spec) + if show_all: + print + if not activated: + tty.msg("None activated.") + else: + tty.msg("%d currently activated:" % len(activated)) + spack.cmd.find.display_specs( + activated.values(), mode=args.mode, long=args.long) |