Fixes #460: Do not show variants by default in spack find.
This does two things: 1. By default `spack find` no longer shows variants. You have to supply `-v` to get that 2. This improves the `colify` implementation so that it no longer pads the rightmost column. This avoids the issue where if one spec was too long in the output, *all* specs would have space padding added to that width, and it would look like the output of `spack find` was double spaced. This no longer happens -- the one bad line wraps around and the other lines are now single-spaced when you use `-v` with boost.
This commit is contained in:
parent
88b671f8b1
commit
17b868381f
@ -198,8 +198,13 @@ def colify(elts, **options):
|
|||||||
for col in xrange(cols):
|
for col in xrange(cols):
|
||||||
elt = col * rows + row
|
elt = col * rows + row
|
||||||
width = config.widths[col] + cextra(elts[elt])
|
width = config.widths[col] + cextra(elts[elt])
|
||||||
|
if col < cols - 1:
|
||||||
fmt = '%%-%ds' % width
|
fmt = '%%-%ds' % width
|
||||||
output.write(fmt % elts[elt])
|
output.write(fmt % elts[elt])
|
||||||
|
else:
|
||||||
|
# Don't pad the rightmost column (sapces can wrap on
|
||||||
|
# small teriminals if one line is overlong)
|
||||||
|
output.write(elts[elt])
|
||||||
|
|
||||||
output.write("\n")
|
output.write("\n")
|
||||||
row += 1
|
row += 1
|
||||||
|
@ -86,6 +86,11 @@ def setup_parser(subparser):
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
dest='missing',
|
dest='missing',
|
||||||
help='Show missing dependencies as well as installed specs.')
|
help='Show missing dependencies as well as installed specs.')
|
||||||
|
subparser.add_argument(
|
||||||
|
'-v', '--variants',
|
||||||
|
action='store_true',
|
||||||
|
dest='variants',
|
||||||
|
help='Show variants in output (can be long)')
|
||||||
subparser.add_argument('-M', '--only-missing',
|
subparser.add_argument('-M', '--only-missing',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
dest='only_missing',
|
dest='only_missing',
|
||||||
@ -107,6 +112,8 @@ 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)
|
||||||
namespace = kwargs.get('namespace', False)
|
namespace = kwargs.get('namespace', False)
|
||||||
|
flags = kwargs.get('show_flags', False)
|
||||||
|
variants = kwargs.get('variants', False)
|
||||||
|
|
||||||
hlen = 7
|
hlen = 7
|
||||||
if kwargs.get('very_long', False):
|
if kwargs.get('very_long', False):
|
||||||
@ -114,10 +121,9 @@ def display_specs(specs, **kwargs):
|
|||||||
hlen = None
|
hlen = None
|
||||||
|
|
||||||
nfmt = '.' if namespace else '_'
|
nfmt = '.' if namespace else '_'
|
||||||
format_string = '$%s$@$+' % nfmt
|
ffmt = '$%+' if flags else ''
|
||||||
flags = kwargs.get('show_flags', False)
|
vfmt = '$+' if variants else ''
|
||||||
if flags:
|
format_string = '$%s$@%s%s' % (nfmt, ffmt, vfmt)
|
||||||
format_string = '$%s$@$%%+$+' % nfmt
|
|
||||||
|
|
||||||
# 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'))
|
||||||
@ -163,7 +169,7 @@ def fmt(s):
|
|||||||
string = ""
|
string = ""
|
||||||
if hashes:
|
if hashes:
|
||||||
string += gray_hash(s, hlen) + ' '
|
string += gray_hash(s, hlen) + ' '
|
||||||
string += s.format('$-%s$@$+' % nfmt, color=True)
|
string += s.format('$-%s$@%s' % (nfmt, vfmt), color=True)
|
||||||
|
|
||||||
return string
|
return string
|
||||||
|
|
||||||
@ -238,4 +244,5 @@ def find(parser, args):
|
|||||||
long=args.long,
|
long=args.long,
|
||||||
very_long=args.very_long,
|
very_long=args.very_long,
|
||||||
show_flags=args.show_flags,
|
show_flags=args.show_flags,
|
||||||
namespace=args.namespace)
|
namespace=args.namespace,
|
||||||
|
variants=args.variants)
|
||||||
|
@ -39,6 +39,13 @@
|
|||||||
b) use spack uninstall -a to uninstall ALL matching specs.
|
b) use spack uninstall -a to uninstall ALL matching specs.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Arguments for display_specs when we find ambiguity
|
||||||
|
display_args = {
|
||||||
|
'long': True,
|
||||||
|
'show_flags': True,
|
||||||
|
'variants':True
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def ask_for_confirmation(message):
|
def ask_for_confirmation(message):
|
||||||
while True:
|
while True:
|
||||||
@ -92,7 +99,7 @@ def concretize_specs(specs, allow_multiple_matches=False, force=False):
|
|||||||
if not allow_multiple_matches and len(matching) > 1:
|
if not allow_multiple_matches and len(matching) > 1:
|
||||||
tty.error("%s matches multiple packages:" % spec)
|
tty.error("%s matches multiple packages:" % spec)
|
||||||
print()
|
print()
|
||||||
display_specs(matching, long=True, show_flags=True)
|
display_specs(matching, **display_args)
|
||||||
print()
|
print()
|
||||||
has_errors = True
|
has_errors = True
|
||||||
|
|
||||||
@ -172,7 +179,7 @@ def uninstall(parser, args):
|
|||||||
tty.error("Will not uninstall %s" % spec.format("$_$@$%@$#", color=True))
|
tty.error("Will not uninstall %s" % spec.format("$_$@$%@$#", color=True))
|
||||||
print('')
|
print('')
|
||||||
print("The following packages depend on it:")
|
print("The following packages depend on it:")
|
||||||
display_specs(lst, long=True)
|
display_specs(lst, **display_args)
|
||||||
print('')
|
print('')
|
||||||
has_error = True
|
has_error = True
|
||||||
elif args.dependents:
|
elif args.dependents:
|
||||||
@ -186,7 +193,7 @@ def uninstall(parser, args):
|
|||||||
if not args.yes_to_all:
|
if not args.yes_to_all:
|
||||||
tty.msg("The following packages will be uninstalled : ")
|
tty.msg("The following packages will be uninstalled : ")
|
||||||
print('')
|
print('')
|
||||||
display_specs(uninstall_list, long=True, show_flags=True)
|
display_specs(uninstall_list, **display_args)
|
||||||
print('')
|
print('')
|
||||||
ask_for_confirmation('Do you want to proceed ? ')
|
ask_for_confirmation('Do you want to proceed ? ')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user