extensions: support only showing a subset of information
This commit is contained in:
parent
b7ec870c3b
commit
4511d9d924
@ -49,6 +49,10 @@ def setup_parser(subparser):
|
|||||||
format_group.add_argument(
|
format_group.add_argument(
|
||||||
'-d', '--deps', action='store_const', dest='mode', const='deps',
|
'-d', '--deps', action='store_const', dest='mode', const='deps',
|
||||||
help='show full dependency DAG of extensions')
|
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(
|
subparser.add_argument(
|
||||||
'-v', '--view', metavar='VIEW', type=str,
|
'-v', '--view', metavar='VIEW', type=str,
|
||||||
help="the view to operate on")
|
help="the view to operate on")
|
||||||
@ -62,6 +66,24 @@ def extensions(parser, args):
|
|||||||
if not args.spec:
|
if not args.spec:
|
||||||
tty.die("extensions requires a package 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
|
# Checks
|
||||||
#
|
#
|
||||||
@ -80,12 +102,13 @@ def extensions(parser, args):
|
|||||||
if not args.mode:
|
if not args.mode:
|
||||||
args.mode = 'short'
|
args.mode = 'short'
|
||||||
|
|
||||||
|
if show_packages:
|
||||||
#
|
#
|
||||||
# List package names of extensions
|
# List package names of extensions
|
||||||
extensions = spack.repo.extensions_for(spec)
|
extensions = spack.repo.extensions_for(spec)
|
||||||
if not extensions:
|
if not extensions:
|
||||||
tty.msg("%s has no extensions." % spec.cshort_spec)
|
tty.msg("%s has no extensions." % spec.cshort_spec)
|
||||||
return
|
else:
|
||||||
tty.msg(spec.cshort_spec)
|
tty.msg(spec.cshort_spec)
|
||||||
tty.msg("%d extensions:" % len(extensions))
|
tty.msg("%d extensions:" % len(extensions))
|
||||||
colify(ext.name for ext in extensions)
|
colify(ext.name for ext in extensions)
|
||||||
@ -94,26 +117,31 @@ def extensions(parser, args):
|
|||||||
if args.view is not None:
|
if args.view is not None:
|
||||||
layout = YamlViewExtensionsLayout(args.view, spack.store.layout)
|
layout = YamlViewExtensionsLayout(args.view, spack.store.layout)
|
||||||
|
|
||||||
|
if show_installed:
|
||||||
#
|
#
|
||||||
# List specs of installed extensions.
|
# List specs of installed extensions.
|
||||||
#
|
#
|
||||||
installed = [s.spec
|
installed = [s.spec
|
||||||
for s in spack.store.db.installed_extensions_for(spec)]
|
for s in spack.store.db.installed_extensions_for(spec)]
|
||||||
|
|
||||||
|
if show_all:
|
||||||
print
|
print
|
||||||
if not installed:
|
if not installed:
|
||||||
tty.msg("None installed.")
|
tty.msg("None installed.")
|
||||||
|
else:
|
||||||
tty.msg("%d installed:" % len(installed))
|
tty.msg("%d installed:" % len(installed))
|
||||||
spack.cmd.find.display_specs(installed, mode=args.mode)
|
spack.cmd.find.display_specs(installed, mode=args.mode)
|
||||||
|
|
||||||
|
if show_activated:
|
||||||
#
|
#
|
||||||
# List specs of activated extensions.
|
# List specs of activated extensions.
|
||||||
#
|
#
|
||||||
activated = layout.extension_map(spec)
|
activated = layout.extension_map(spec)
|
||||||
|
if show_all:
|
||||||
print
|
print
|
||||||
if not activated:
|
if not activated:
|
||||||
tty.msg("None activated.")
|
tty.msg("None activated.")
|
||||||
return
|
else:
|
||||||
tty.msg("%d currently activated:" % len(activated))
|
tty.msg("%d currently activated:" % len(activated))
|
||||||
spack.cmd.find.display_specs(
|
spack.cmd.find.display_specs(
|
||||||
activated.values(), mode=args.mode, long=args.long)
|
activated.values(), mode=args.mode, long=args.long)
|
||||||
|
Loading…
Reference in New Issue
Block a user