Add namespace option to find command.
This commit is contained in:
parent
358b2ab4ba
commit
5984bc2ad3
@ -40,6 +40,9 @@
|
||||
|
||||
def setup_parser(subparser):
|
||||
format_group = subparser.add_mutually_exclusive_group()
|
||||
format_group.add_argument(
|
||||
'-s', '--short', action='store_const', dest='mode', const='short',
|
||||
help='Show only specs (default)')
|
||||
format_group.add_argument(
|
||||
'-p', '--paths', action='store_const', dest='mode', const='paths',
|
||||
help='Show paths to package install directories')
|
||||
@ -48,21 +51,24 @@ def setup_parser(subparser):
|
||||
help='Show full dependency DAG of installed packages')
|
||||
|
||||
subparser.add_argument(
|
||||
'-l', '--long', action='store_true', dest='long',
|
||||
'-l', '--long', action='store_true',
|
||||
help='Show dependency hashes as well as versions.')
|
||||
subparser.add_argument(
|
||||
'-L', '--very-long', action='store_true', dest='very_long',
|
||||
'-L', '--very-long', action='store_true',
|
||||
help='Show dependency hashes as well as versions.')
|
||||
|
||||
subparser.add_argument(
|
||||
'-u', '--unknown', action='store_true', dest='unknown',
|
||||
'-u', '--unknown', action='store_true',
|
||||
help='Show only specs Spack does not have a package for.')
|
||||
subparser.add_argument(
|
||||
'-m', '--missing', action='store_true', dest='missing',
|
||||
'-m', '--missing', action='store_true',
|
||||
help='Show missing dependencies as well as installed specs.')
|
||||
subparser.add_argument(
|
||||
'-M', '--only-missing', action='store_true', dest='only_missing',
|
||||
'-M', '--only-missing', action='store_true',
|
||||
help='Show only missing dependencies.')
|
||||
subparser.add_argument(
|
||||
'-N', '--namespace', action='store_true',
|
||||
help='Show fully qualified package names.')
|
||||
|
||||
subparser.add_argument(
|
||||
'query_specs', nargs=argparse.REMAINDER,
|
||||
@ -76,6 +82,7 @@ def gray_hash(spec, length):
|
||||
def display_specs(specs, **kwargs):
|
||||
mode = kwargs.get('mode', 'short')
|
||||
hashes = kwargs.get('long', False)
|
||||
namespace = kwargs.get('namespace', False)
|
||||
|
||||
hlen = 7
|
||||
if kwargs.get('very_long', False):
|
||||
@ -97,7 +104,8 @@ def display_specs(specs, **kwargs):
|
||||
specs = index[(architecture,compiler)]
|
||||
specs.sort()
|
||||
|
||||
abbreviated = [s.format('$_$@$+', color=True) for s in specs]
|
||||
nfmt = '.' if namespace else '_'
|
||||
abbreviated = [s.format('$%s$@$+' % nfmt, color=True) for s in specs]
|
||||
if mode == 'paths':
|
||||
# Print one spec per line along with prefix path
|
||||
width = max(len(s) for s in abbreviated)
|
||||
@ -112,7 +120,7 @@ def display_specs(specs, **kwargs):
|
||||
elif mode == 'deps':
|
||||
for spec in specs:
|
||||
print spec.tree(
|
||||
format='$_$@$+',
|
||||
format='$%s$@$+' % nfmt,
|
||||
color=True,
|
||||
indent=4,
|
||||
prefix=(lambda s: gray_hash(s, hlen)) if hashes else None)
|
||||
@ -122,7 +130,7 @@ def fmt(s):
|
||||
string = ""
|
||||
if hashes:
|
||||
string += gray_hash(s, hlen) + ' '
|
||||
string += s.format('$-_$@$+', color=True)
|
||||
string += s.format('$-%s$@$+' % nfmt, color=True)
|
||||
|
||||
return string
|
||||
colify(fmt(s) for s in specs)
|
||||
@ -171,4 +179,5 @@ def find(parser, args):
|
||||
tty.msg("%d installed packages." % len(specs))
|
||||
display_specs(specs, mode=args.mode,
|
||||
long=args.long,
|
||||
very_long=args.very_long)
|
||||
very_long=args.very_long,
|
||||
namespace=args.namespace)
|
||||
|
Loading…
Reference in New Issue
Block a user