from portage import digraph
import emergehelp, xpak, commands, errno, re, socket, string, time, types
+import output
from output import blue, bold, colorize, darkblue, darkgreen, darkred, green, \
havecolor, nc_len, nocolor, red, teal, turquoise, white, xtermTitle, \
xtermTitleReset, yellow
longopt_aliases = {"--cols":"--columns", "--skip-first":"--skipfirst"}
argument_options = {
+ "--color": {
+ "help":"enable or disable color output",
+ "type":"choice",
+ "choices":("y", "n")
+ },
"--with-bdeps": {
"help":"include unnecessary build time dependencies",
"type":"choice",
else:
myfiles.append(x)
+ if "--nocolor" in myopts:
+ print "*** Deprecated use of '--nocolor', use '--color=n' instead."
+ del myopts["--nocolor"]
+ myopts["--color"] = "n"
+
return myaction, myopts, myfiles
def validate_ebuild_environment(trees):
settings["PORTAGE_DEBUG"] = str(PORTAGE_DEBUG)
settings.backup_changes("PORTAGE_DEBUG")
- # Set color output
- if "--nocolor" in myopts:
+ """The explicit --color < y | n > option overrides the NOCOLOR environment
+ variable and stdout auto-detection."""
+ if "--color" in myopts:
+ if "y" == myopts["--color"]:
+ output.havecolor = 1
+ settings["NOCOLOR"] = "false"
+ else:
+ output.havecolor = 0
+ settings["NOCOLOR"] = "true"
+ settings.backup_changes("NOCOLOR")
+ elif not sys.stdout.isatty():
+ output.havecolor = 0
settings["NOCOLOR"] = "true"
settings.backup_changes("NOCOLOR")
ldpath_mtimes = mtimedb["ldpath"]
xterm_titles = "notitles" not in settings.features
+ """Disable color as early as possible via NOCOLOR and stdout
+ auto-detection. This initial setting may later be overridden via the
+ --color < yes | no > option."""
if settings.get("NOCOLOR","").lower() in ("yes","true"):
nocolor()
elif (not sys.stdout.isatty()) and \
print "* --tree is currently broken with --resume. Disabling..."
del myopts["--tree"]
- # Set color output
- if "--nocolor" in myopts or \
- settings["NOCOLOR"] in ("yes","true"):
- nocolor()
-
if not ("--quiet" in myopts):
if not sys.stdout.isatty() or ("--nospinner" in myopts):
spinner.update = spinner.update_basic
trees[settings["ROOT"]]["vartree"].dbapi)
sys.exit(0)
elif "--help" in myopts:
- emergehelp.help(myaction, myopts, havecolor)
+ emergehelp.help(myaction, myopts, output.havecolor)
sys.exit(0)
if portage.wheelgid == portage.portage_gid:
print "myopts", myopts
if not myaction and not myfiles and "--resume" not in myopts:
- emergehelp.help(myaction, myopts, havecolor)
+ emergehelp.help(myaction, myopts, output.havecolor)
sys.exit(1)
# check if root user is the current user for the actions where emerge needs this