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:
		@@ -198,8 +198,13 @@ def colify(elts, **options):
 | 
			
		||||
        for col in xrange(cols):
 | 
			
		||||
            elt = col * rows + row
 | 
			
		||||
            width = config.widths[col] + cextra(elts[elt])
 | 
			
		||||
            if col < cols - 1:
 | 
			
		||||
                fmt = '%%-%ds' % width
 | 
			
		||||
                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")
 | 
			
		||||
        row += 1
 | 
			
		||||
 
 | 
			
		||||
@@ -86,6 +86,11 @@ def setup_parser(subparser):
 | 
			
		||||
        action='store_true',
 | 
			
		||||
        dest='missing',
 | 
			
		||||
        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',
 | 
			
		||||
                           action='store_true',
 | 
			
		||||
                           dest='only_missing',
 | 
			
		||||
@@ -107,6 +112,8 @@ def display_specs(specs, **kwargs):
 | 
			
		||||
    mode = kwargs.get('mode', 'short')
 | 
			
		||||
    hashes = kwargs.get('long', False)
 | 
			
		||||
    namespace = kwargs.get('namespace', False)
 | 
			
		||||
    flags = kwargs.get('show_flags', False)
 | 
			
		||||
    variants = kwargs.get('variants', False)
 | 
			
		||||
 | 
			
		||||
    hlen = 7
 | 
			
		||||
    if kwargs.get('very_long', False):
 | 
			
		||||
@@ -114,10 +121,9 @@ def display_specs(specs, **kwargs):
 | 
			
		||||
        hlen = None
 | 
			
		||||
 | 
			
		||||
    nfmt = '.' if namespace else '_'
 | 
			
		||||
    format_string = '$%s$@$+' % nfmt
 | 
			
		||||
    flags = kwargs.get('show_flags', False)
 | 
			
		||||
    if flags:
 | 
			
		||||
        format_string = '$%s$@$%%+$+' % nfmt
 | 
			
		||||
    ffmt = '$%+' if flags else ''
 | 
			
		||||
    vfmt = '$+' if variants else ''
 | 
			
		||||
    format_string = '$%s$@%s%s' % (nfmt, ffmt, vfmt)
 | 
			
		||||
 | 
			
		||||
    # Make a dict with specs keyed by architecture and compiler.
 | 
			
		||||
    index = index_by(specs, ('architecture', 'compiler'))
 | 
			
		||||
@@ -163,7 +169,7 @@ def fmt(s):
 | 
			
		||||
                    string = ""
 | 
			
		||||
                    if hashes:
 | 
			
		||||
                        string += gray_hash(s, hlen) + ' '
 | 
			
		||||
                    string += s.format('$-%s$@$+' % nfmt, color=True)
 | 
			
		||||
                    string += s.format('$-%s$@%s' % (nfmt, vfmt), color=True)
 | 
			
		||||
 | 
			
		||||
                    return string
 | 
			
		||||
 | 
			
		||||
@@ -238,4 +244,5 @@ def find(parser, args):
 | 
			
		||||
                  long=args.long,
 | 
			
		||||
                  very_long=args.very_long,
 | 
			
		||||
                  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.
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
# Arguments for display_specs when we find ambiguity
 | 
			
		||||
display_args = {
 | 
			
		||||
    'long': True,
 | 
			
		||||
    'show_flags': True,
 | 
			
		||||
    'variants':True
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def ask_for_confirmation(message):
 | 
			
		||||
    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:
 | 
			
		||||
            tty.error("%s matches multiple packages:" % spec)
 | 
			
		||||
            print()
 | 
			
		||||
            display_specs(matching, long=True, show_flags=True)
 | 
			
		||||
            display_specs(matching, **display_args)
 | 
			
		||||
            print()
 | 
			
		||||
            has_errors = True
 | 
			
		||||
 | 
			
		||||
@@ -172,7 +179,7 @@ def uninstall(parser, args):
 | 
			
		||||
                tty.error("Will not uninstall %s" % spec.format("$_$@$%@$#", color=True))
 | 
			
		||||
                print('')
 | 
			
		||||
                print("The following packages depend on it:")
 | 
			
		||||
                display_specs(lst, long=True)
 | 
			
		||||
                display_specs(lst, **display_args)
 | 
			
		||||
                print('')
 | 
			
		||||
                has_error = True
 | 
			
		||||
        elif args.dependents:
 | 
			
		||||
@@ -186,7 +193,7 @@ def uninstall(parser, args):
 | 
			
		||||
        if not args.yes_to_all:
 | 
			
		||||
            tty.msg("The following packages will be uninstalled : ")
 | 
			
		||||
            print('')
 | 
			
		||||
            display_specs(uninstall_list, long=True, show_flags=True)
 | 
			
		||||
            display_specs(uninstall_list, **display_args)
 | 
			
		||||
            print('')
 | 
			
		||||
            ask_for_confirmation('Do you want to proceed ? ')
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user