Add spack find -L to show full hashes.
This commit is contained in:
parent
8cbae642cc
commit
5676cb0dd1
@ -50,20 +50,28 @@ def setup_parser(subparser):
|
|||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'-l', '--long', action='store_true', dest='long',
|
'-l', '--long', action='store_true', dest='long',
|
||||||
help='Show dependency hashes as well as versions.')
|
help='Show dependency hashes as well as versions.')
|
||||||
|
subparser.add_argument(
|
||||||
|
'-L', '--very-long', action='store_true', dest='very_long',
|
||||||
|
help='Show dependency hashes as well as versions.')
|
||||||
|
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'query_specs', nargs=argparse.REMAINDER,
|
'query_specs', nargs=argparse.REMAINDER,
|
||||||
help='optional specs to filter results')
|
help='optional specs to filter results')
|
||||||
|
|
||||||
|
|
||||||
def gray_hash(spec):
|
def gray_hash(spec, length):
|
||||||
return colorize('@K{[%s]}' % spec.dag_hash(7))
|
return colorize('@K{%s}' % spec.dag_hash(length))
|
||||||
|
|
||||||
|
|
||||||
def display_specs(specs, **kwargs):
|
def display_specs(specs, **kwargs):
|
||||||
mode = kwargs.get('mode', 'short')
|
mode = kwargs.get('mode', 'short')
|
||||||
hashes = kwargs.get('long', False)
|
hashes = kwargs.get('long', False)
|
||||||
|
|
||||||
|
hlen = 7
|
||||||
|
if kwargs.get('very_long', False):
|
||||||
|
hashes = True
|
||||||
|
hlen = None
|
||||||
|
|
||||||
# Make a dict with specs keyed by architecture and compiler.
|
# Make a dict with specs keyed by architecture and compiler.
|
||||||
index = index_by(specs, ('architecture', 'compiler'))
|
index = index_by(specs, ('architecture', 'compiler'))
|
||||||
|
|
||||||
@ -87,6 +95,8 @@ def display_specs(specs, **kwargs):
|
|||||||
format = " %-{}s%s".format(width)
|
format = " %-{}s%s".format(width)
|
||||||
|
|
||||||
for abbrv, spec in zip(abbreviated, specs):
|
for abbrv, spec in zip(abbreviated, specs):
|
||||||
|
if hashes:
|
||||||
|
print gray_hash(spec, hlen),
|
||||||
print format % (abbrv, spec.prefix)
|
print format % (abbrv, spec.prefix)
|
||||||
|
|
||||||
elif mode == 'deps':
|
elif mode == 'deps':
|
||||||
@ -95,13 +105,13 @@ def display_specs(specs, **kwargs):
|
|||||||
format='$_$@$+',
|
format='$_$@$+',
|
||||||
color=True,
|
color=True,
|
||||||
indent=4,
|
indent=4,
|
||||||
prefix=(lambda s: gray_hash(s)) if hashes else None)
|
prefix=(lambda s: gray_hash(s, hlen)) if hashes else None)
|
||||||
|
|
||||||
elif mode == 'short':
|
elif mode == 'short':
|
||||||
def fmt(s):
|
def fmt(s):
|
||||||
string = ""
|
string = ""
|
||||||
if hashes:
|
if hashes:
|
||||||
string += gray_hash(s) + ' '
|
string += gray_hash(s, hlen) + ' '
|
||||||
string += s.format('$-_$@$+', color=True)
|
string += s.format('$-_$@$+', color=True)
|
||||||
return string
|
return string
|
||||||
colify(fmt(s) for s in specs)
|
colify(fmt(s) for s in specs)
|
||||||
@ -138,4 +148,6 @@ def find(parser, args):
|
|||||||
|
|
||||||
if sys.stdout.isatty():
|
if sys.stdout.isatty():
|
||||||
tty.msg("%d installed packages." % len(specs))
|
tty.msg("%d installed packages." % len(specs))
|
||||||
display_specs(specs, mode=args.mode, long=args.long)
|
display_specs(specs, mode=args.mode,
|
||||||
|
long=args.long,
|
||||||
|
very_long=args.very_long)
|
||||||
|
Loading…
Reference in New Issue
Block a user