Better location error output.

This commit is contained in:
Todd Gamblin 2015-01-19 14:05:48 -08:00
parent a4c19eee14
commit f35b8b8db4

View File

@ -23,6 +23,7 @@
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import os import os
import sys
from external import argparse from external import argparse
import llnl.util.tty as tty import llnl.util.tty as tty
@ -86,11 +87,12 @@ def location(parser, args):
tty.die("Spec '%s' matches no installed packages." % spec) tty.die("Spec '%s' matches no installed packages." % spec)
elif len(matching_specs) > 1: elif len(matching_specs) > 1:
args = ["%s matches multiple packages." % spec, tty.error("%s matches multiple packages:" % spec)
"Matching packages:"] for s in matching_specs:
args += [" " + str(s) for s in matching_specs] sys.stderr.write(s.tree(color=True))
args += ["Use a more specific spec."] sys.stderr.write("\n")
tty.die(*args) sys.stderr.write("Use a more specific spec.\n")
sys.exit(1)
print matching_specs[0].prefix print matching_specs[0].prefix