aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Fabio Correa <facorread@gmail.com> 2009-04-23 15:12:01 -0500
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-05 18:24:06 +0100
commitc7586cd9db07a36c7a8e69567ee2c268b9b4035c (patch)
tree085256aeee661b440cbd77bd1ae1cbeb152f8579
parent8022c7fa08e2e81d3951f5376064732f8a502929 (diff)
downloadpaludis-c7586cd9db07a36c7a8e69567ee2c268b9b4035c.tar.gz
paludis-c7586cd9db07a36c7a8e69567ee2c268b9b4035c.tar.xz
Implement --force-colour, fixes:503
-rw-r--r--src/clients/accerso/accerso.cc4
-rw-r--r--src/clients/accerso/command_line.cc2
-rw-r--r--src/clients/accerso/command_line.hh2
-rw-r--r--src/clients/adjutrix/adjutrix.cc3
-rw-r--r--src/clients/adjutrix/command_line.cc2
-rw-r--r--src/clients/adjutrix/command_line.hh2
-rw-r--r--src/clients/appareo/appareo.cc3
-rw-r--r--src/clients/appareo/command_line.cc2
-rw-r--r--src/clients/appareo/command_line.hh2
-rw-r--r--src/clients/importare/command_line.cc2
-rw-r--r--src/clients/importare/command_line.hh2
-rw-r--r--src/clients/importare/importare.cc6
-rw-r--r--src/clients/inquisitio/command_line.cc2
-rw-r--r--src/clients/inquisitio/command_line.hh2
-rw-r--r--src/clients/inquisitio/inquisitio.cc6
-rw-r--r--src/clients/instruo/command_line.cc2
-rw-r--r--src/clients/instruo/command_line.hh2
-rw-r--r--src/clients/instruo/instruo.cc3
-rw-r--r--src/clients/paludis/command_line.cc2
-rw-r--r--src/clients/paludis/command_line.hh6
-rw-r--r--src/clients/paludis/paludis.cc6
-rw-r--r--src/clients/reconcilio/command_line.cc2
-rw-r--r--src/clients/reconcilio/command_line.hh2
-rw-r--r--src/clients/reconcilio/reconcilio.cc4
-rw-r--r--src/output/colour.cc10
-rw-r--r--src/output/colour.hh1
26 files changed, 75 insertions, 7 deletions
diff --git a/src/clients/accerso/accerso.cc b/src/clients/accerso/accerso.cc
index 1e2ebc5..5de028a 100644
--- a/src/clients/accerso/accerso.cc
+++ b/src/clients/accerso/accerso.cc
@@ -64,9 +64,11 @@ main(int argc, char *argv[])
try
{
CommandLine::get_instance()->run(argc, argv, "accerso", "ACCERSO_OPTIONS", "ACCERSO_CMDLINE");
+
set_use_colour(
- (! CommandLine::get_instance()->a_no_color.specified()) &&
+ (! CommandLine::get_instance()->a_no_colour.specified()) &&
(! CommandLine::get_instance()->a_report_file.specified()));
+ set_force_colour(CommandLine::get_instance()->a_force_colour.specified());
if (CommandLine::get_instance()->a_help.specified())
throw args::DoHelp();
diff --git a/src/clients/accerso/command_line.cc b/src/clients/accerso/command_line.cc
index d5ea32b..74f94d2 100644
--- a/src/clients/accerso/command_line.cc
+++ b/src/clients/accerso/command_line.cc
@@ -39,6 +39,8 @@ CommandLine::CommandLine() :
a_log_level(&general_args, "log-level", '\0'),
a_no_colour(&general_args, "no-colour", '\0', "Do not use colour", false),
a_no_color(&a_no_colour, "no-color"),
+ a_force_colour(&general_args, "force-colour", '\0', "Force the use of colour", false),
+ a_force_color(&a_force_colour, "force-color"),
a_repository_directory(&general_args, "repository-dir", 'D',
"Where to find the repository (default: current directory)"),
a_download_directory(&general_args, "download-dir", 'd',
diff --git a/src/clients/accerso/command_line.hh b/src/clients/accerso/command_line.hh
index 16131d0..4964f5b 100644
--- a/src/clients/accerso/command_line.hh
+++ b/src/clients/accerso/command_line.hh
@@ -51,6 +51,8 @@ class CommandLine :
paludis::args::LogLevelArg a_log_level;
paludis::args::SwitchArg a_no_colour;
paludis::args::AliasArg a_no_color;
+ paludis::args::SwitchArg a_force_colour;
+ paludis::args::AliasArg a_force_color;
paludis::args::StringArg a_repository_directory;
paludis::args::StringArg a_download_directory;
paludis::args::StringArg a_master_repository_name;
diff --git a/src/clients/adjutrix/adjutrix.cc b/src/clients/adjutrix/adjutrix.cc
index bc7391a..7f5a6b4 100644
--- a/src/clients/adjutrix/adjutrix.cc
+++ b/src/clients/adjutrix/adjutrix.cc
@@ -97,7 +97,8 @@ main(int argc, char *argv[])
try
{
CommandLine::get_instance()->run(argc, argv, "adjutrix", "ADJUTRIX_OPTIONS", "ADJUTRIX_CMDLINE");
- set_use_colour(! CommandLine::get_instance()->a_no_color.specified());
+ set_use_colour(! CommandLine::get_instance()->a_no_colour.specified());
+ set_force_colour(CommandLine::get_instance()->a_force_colour.specified());
if (1 != isatty(1))
CommandLine::get_instance()->a_no_suggestions.set_specified(true);
diff --git a/src/clients/adjutrix/command_line.cc b/src/clients/adjutrix/command_line.cc
index 39c1e62..bc20eba 100644
--- a/src/clients/adjutrix/command_line.cc
+++ b/src/clients/adjutrix/command_line.cc
@@ -76,6 +76,8 @@ CommandLine::CommandLine() :
a_log_level(&general_args, "log-level", '\0'),
a_no_colour(&general_args, "no-colour", '\0', "Do not use colour", false),
a_no_color(&a_no_colour, "no-color"),
+ a_force_colour(&general_args, "force-colour", '\0', "Force the use of colour", false),
+ a_force_color(&a_force_colour, "force-color"),
a_no_suggestions(&general_args, "no-suggestions", '\0', "Do not give suggestions if an unknown name is specified", false),
a_repository_directory(&general_args, "repository-dir", 'D',
diff --git a/src/clients/adjutrix/command_line.hh b/src/clients/adjutrix/command_line.hh
index 6de86fb..f60265b 100644
--- a/src/clients/adjutrix/command_line.hh
+++ b/src/clients/adjutrix/command_line.hh
@@ -88,6 +88,8 @@ class CommandLine :
paludis::args::LogLevelArg a_log_level;
paludis::args::SwitchArg a_no_colour;
paludis::args::AliasArg a_no_color;
+ paludis::args::SwitchArg a_force_colour;
+ paludis::args::AliasArg a_force_color;
paludis::args::SwitchArg a_no_suggestions;
paludis::args::StringArg a_repository_directory;
diff --git a/src/clients/appareo/appareo.cc b/src/clients/appareo/appareo.cc
index 0c51a71..2e5dcf5 100644
--- a/src/clients/appareo/appareo.cc
+++ b/src/clients/appareo/appareo.cc
@@ -170,8 +170,9 @@ main(int argc, char *argv[])
{
CommandLine::get_instance()->run(argc, argv, "appareo", "APPAREO_OPTIONS", "APPAREO_CMDLINE");
set_use_colour(
- (! CommandLine::get_instance()->a_no_color.specified()) &&
+ (! CommandLine::get_instance()->a_no_colour.specified()) &&
(! CommandLine::get_instance()->a_report_file.specified()));
+ set_force_colour(CommandLine::get_instance()->a_force_colour.specified());
if (CommandLine::get_instance()->a_help.specified())
throw args::DoHelp();
diff --git a/src/clients/appareo/command_line.cc b/src/clients/appareo/command_line.cc
index d5324ec..1361e54 100644
--- a/src/clients/appareo/command_line.cc
+++ b/src/clients/appareo/command_line.cc
@@ -40,6 +40,8 @@ CommandLine::CommandLine() :
a_log_level(&general_args, "log-level", '\0'),
a_no_colour(&general_args, "no-colour", '\0', "Do not use colour", false),
a_no_color(&a_no_colour, "no-color"),
+ a_force_colour(&general_args, "force-colour", '\0', "Force the use of colour", false),
+ a_force_color(&a_force_colour, "force-color"),
a_repository_directory(&general_args, "repository-dir", 'D',
"Where to find the repository (default: current directory)"),
a_download_directory(&general_args, "download-dir", 'd',
diff --git a/src/clients/appareo/command_line.hh b/src/clients/appareo/command_line.hh
index 0537f59..422a455 100644
--- a/src/clients/appareo/command_line.hh
+++ b/src/clients/appareo/command_line.hh
@@ -52,6 +52,8 @@ class CommandLine :
paludis::args::LogLevelArg a_log_level;
paludis::args::SwitchArg a_no_colour;
paludis::args::AliasArg a_no_color;
+ paludis::args::SwitchArg a_force_colour;
+ paludis::args::AliasArg a_force_color;
paludis::args::StringArg a_repository_directory;
paludis::args::StringArg a_download_directory;
paludis::args::StringArg a_master_repository_name;
diff --git a/src/clients/importare/command_line.cc b/src/clients/importare/command_line.cc
index 10b1cbc..410442b 100644
--- a/src/clients/importare/command_line.cc
+++ b/src/clients/importare/command_line.cc
@@ -39,6 +39,8 @@ CommandLine::CommandLine() :
a_log_level(&general_args, "log-level", '\0'),
a_no_colour(&general_args, "no-colour", '\0', "Do not use colour", false),
a_no_color(&a_no_colour, "no-color"),
+ a_force_colour(&general_args, "force-colour", '\0', "Force the use of colour", false),
+ a_force_color(&a_force_colour, "force-color"),
a_environment(&general_args, "environment", 'E', "Environment specification (class:suffix, both parts optional)"),
a_compact(&general_args, "compact", '\0', "Display output using one line per entry", true),
diff --git a/src/clients/importare/command_line.hh b/src/clients/importare/command_line.hh
index 85c1184..eb43d8a 100644
--- a/src/clients/importare/command_line.hh
+++ b/src/clients/importare/command_line.hh
@@ -50,6 +50,8 @@ class CommandLine :
paludis::args::LogLevelArg a_log_level;
paludis::args::SwitchArg a_no_colour;
paludis::args::AliasArg a_no_color;
+ paludis::args::SwitchArg a_force_colour;
+ paludis::args::AliasArg a_force_color;
paludis::args::StringArg a_environment;
paludis::args::SwitchArg a_compact;
diff --git a/src/clients/importare/importare.cc b/src/clients/importare/importare.cc
index 9f77f9e..c6312d1 100644
--- a/src/clients/importare/importare.cc
+++ b/src/clients/importare/importare.cc
@@ -89,7 +89,8 @@ main(int argc, char *argv[])
try
{
CommandLine::get_instance()->run(argc, argv, "importare", "IMPORTARE_OPTIONS", "IMPORTARE_CMDLINE");
- set_use_colour(! CommandLine::get_instance()->a_no_color.specified());
+ set_use_colour(! CommandLine::get_instance()->a_no_colour.specified());
+ set_force_colour(CommandLine::get_instance()->a_force_colour.specified());
if (CommandLine::get_instance()->a_help.specified())
throw args::DoHelp();
@@ -125,6 +126,9 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_no_color.specified())
paludis_command.append(" --" + CommandLine::get_instance()->a_no_color.long_name());
+ if (CommandLine::get_instance()->a_force_color.specified())
+ paludis_command.append(" --" + CommandLine::get_instance()->a_force_color.long_name());
+
paludis_command.append(CommandLine::get_instance()->install_args.paludis_command_fragment());
paludis_command.append(CommandLine::get_instance()->dl_args.paludis_command_fragment());
diff --git a/src/clients/inquisitio/command_line.cc b/src/clients/inquisitio/command_line.cc
index b09507e..a1f42d8 100644
--- a/src/clients/inquisitio/command_line.cc
+++ b/src/clients/inquisitio/command_line.cc
@@ -40,6 +40,8 @@ CommandLine::CommandLine() :
a_log_level(&general_args, "log-level", '\0'),
a_no_colour(&general_args, "no-colour", '\0', "Do not use colour", false),
a_no_color(&a_no_colour, "no-color"),
+ a_force_colour(&general_args, "force-colour", '\0', "Force the use of colour", false),
+ a_force_color(&a_force_colour, "force-color"),
a_environment(&general_args, "environment", 'E', "Environment specification (class:suffix, both parts optional)"),
match_args(main_options_section(), "Matching options",
diff --git a/src/clients/inquisitio/command_line.hh b/src/clients/inquisitio/command_line.hh
index 06e6066..ae48984 100644
--- a/src/clients/inquisitio/command_line.hh
+++ b/src/clients/inquisitio/command_line.hh
@@ -62,6 +62,8 @@ class CommandLine :
paludis::args::LogLevelArg a_log_level;
paludis::args::SwitchArg a_no_colour;
paludis::args::AliasArg a_no_color;
+ paludis::args::SwitchArg a_force_colour;
+ paludis::args::AliasArg a_force_color;
paludis::args::StringArg a_environment;
///}
diff --git a/src/clients/inquisitio/inquisitio.cc b/src/clients/inquisitio/inquisitio.cc
index e1476d0..aa2d9ed 100644
--- a/src/clients/inquisitio/inquisitio.cc
+++ b/src/clients/inquisitio/inquisitio.cc
@@ -67,7 +67,8 @@ main(int argc, char *argv[])
try
{
CommandLine::get_instance()->run(argc, argv, "inquisitio", "INQUISITIO_OPTIONS", "INQUISITIO_CMDLINE");
- set_use_colour(! CommandLine::get_instance()->a_no_color.specified());
+ set_use_colour(! CommandLine::get_instance()->a_no_colour.specified());
+ set_force_colour(CommandLine::get_instance()->a_force_colour.specified());
if (CommandLine::get_instance()->a_help.specified())
throw args::DoHelp();
@@ -101,6 +102,9 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_no_color.specified())
paludis_command.append(" --" + CommandLine::get_instance()->a_no_color.long_name());
+ if (CommandLine::get_instance()->a_force_color.specified())
+ paludis_command.append(" --" + CommandLine::get_instance()->a_force_color.long_name());
+
std::tr1::shared_ptr<Environment> env(EnvironmentFactory::get_instance()->create(env_spec));
env->set_paludis_command(paludis_command);
diff --git a/src/clients/instruo/command_line.cc b/src/clients/instruo/command_line.cc
index 93ad16c..506b342 100644
--- a/src/clients/instruo/command_line.cc
+++ b/src/clients/instruo/command_line.cc
@@ -39,6 +39,8 @@ CommandLine::CommandLine() :
a_log_level(&general_args, "log-level", '\0'),
a_no_colour(&general_args, "no-colour", '\0', "Do not use colour", false),
a_no_color(&a_no_colour, "no-color"),
+ a_force_colour(&general_args, "force-colour", '\0', "Force the use of colour", false),
+ a_force_color(&a_force_colour, "force-color"),
a_repository_directory(&general_args, "repository-dir", 'D',
"Where to find the repository (default: current directory)"),
a_output_directory(&general_args, "output-dir", 'o',
diff --git a/src/clients/instruo/command_line.hh b/src/clients/instruo/command_line.hh
index 3addac0..b54ecd9 100644
--- a/src/clients/instruo/command_line.hh
+++ b/src/clients/instruo/command_line.hh
@@ -51,6 +51,8 @@ class CommandLine :
paludis::args::LogLevelArg a_log_level;
paludis::args::SwitchArg a_no_colour;
paludis::args::AliasArg a_no_color;
+ paludis::args::SwitchArg a_force_colour;
+ paludis::args::AliasArg a_force_color;
paludis::args::StringArg a_repository_directory;
paludis::args::StringArg a_output_directory;
paludis::args::StringArg a_master_repository_name;
diff --git a/src/clients/instruo/instruo.cc b/src/clients/instruo/instruo.cc
index 6e8259d..cee8dec 100644
--- a/src/clients/instruo/instruo.cc
+++ b/src/clients/instruo/instruo.cc
@@ -272,8 +272,9 @@ main(int argc, char *argv[])
{
CommandLine::get_instance()->run(argc, argv, "instruo", "INSTRUO_OPTIONS", "INSTRUO_CMDLINE");
set_use_colour(
- (! CommandLine::get_instance()->a_no_color.specified()) &&
+ (! CommandLine::get_instance()->a_no_colour.specified()) &&
(! CommandLine::get_instance()->a_report_file.specified()));
+ set_force_colour(CommandLine::get_instance()->a_force_colour.specified());
if (CommandLine::get_instance()->a_help.specified())
throw args::DoHelp();
diff --git a/src/clients/paludis/command_line.cc b/src/clients/paludis/command_line.cc
index 6b666a2..b0a7cd5 100644
--- a/src/clients/paludis/command_line.cc
+++ b/src/clients/paludis/command_line.cc
@@ -70,6 +70,8 @@ CommandLine::CommandLine() :
a_log_level(&general_args, "log-level", '\0'),
a_no_colour(&general_args, "no-colour", '\0', "Do not use colour", false),
a_no_color(&a_no_colour, "no-color"),
+ a_force_colour(&general_args, "force-colour", '\0', "Force the use of colour", false),
+ a_force_color(&a_force_colour, "force-color"),
a_no_suggestions(&general_args, "no-suggestions", '\0', "Do not give suggestions if an unknown name is specified", false),
a_environment(&general_args, "environment", 'E', "Environment specification (class:suffix, both parts optional)"),
a_resume_command_template(&general_args, "resume-command-template", '\0',
diff --git a/src/clients/paludis/command_line.hh b/src/clients/paludis/command_line.hh
index 2b895f1..a62a57c 100644
--- a/src/clients/paludis/command_line.hh
+++ b/src/clients/paludis/command_line.hh
@@ -160,6 +160,12 @@ class CommandLine :
/// --no-color
paludis::args::AliasArg a_no_color;
+ /// --force-colour
+ paludis::args::SwitchArg a_force_colour;
+
+ /// --force-color
+ paludis::args::AliasArg a_force_color;
+
/// --no-suggestions
paludis::args::SwitchArg a_no_suggestions;
diff --git a/src/clients/paludis/paludis.cc b/src/clients/paludis/paludis.cc
index 561f4c0..18397c3 100644
--- a/src/clients/paludis/paludis.cc
+++ b/src/clients/paludis/paludis.cc
@@ -93,7 +93,8 @@ main(int argc, char *argv[])
try
{
CommandLine::get_instance()->run(argc, argv, "paludis", "PALUDIS_OPTIONS", "PALUDIS_CMDLINE");
- set_use_colour(! CommandLine::get_instance()->a_no_color.specified());
+ set_use_colour(! CommandLine::get_instance()->a_no_colour.specified());
+ set_force_colour(CommandLine::get_instance()->a_force_colour.specified());
if (1 != isatty(1))
CommandLine::get_instance()->a_no_suggestions.set_specified(true);
@@ -170,6 +171,9 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_no_color.specified())
paludis_command.append(" --" + CommandLine::get_instance()->a_no_color.long_name());
+ if (CommandLine::get_instance()->a_force_color.specified())
+ paludis_command.append(" --" + CommandLine::get_instance()->a_force_color.long_name());
+
paludis_command.append(CommandLine::get_instance()->install_args.paludis_command_fragment());
paludis_command.append(CommandLine::get_instance()->dl_args.paludis_command_fragment());
diff --git a/src/clients/reconcilio/command_line.cc b/src/clients/reconcilio/command_line.cc
index cb2ad78..57e7c86 100644
--- a/src/clients/reconcilio/command_line.cc
+++ b/src/clients/reconcilio/command_line.cc
@@ -40,6 +40,8 @@ CommandLine::CommandLine() :
a_log_level(&general_args, "log-level", '\0'),
a_no_colour(&general_args, "no-colour", '\0', "Do not use colour", false),
a_no_color(&a_no_colour, "no-color"),
+ a_force_colour(&general_args, "force-colour", '\0', "Force the use of colour", false),
+ a_force_color(&a_force_colour, "force-color"),
a_environment(&general_args, "environment", 'E', "Environment specification (class:suffix, both parts optional)"),
a_exact(&general_args, "exact", '\0', "Rebuild the same package version that is currently installed", true),
a_resume_command_template(&general_args, "resume-command-template", '\0',
diff --git a/src/clients/reconcilio/command_line.hh b/src/clients/reconcilio/command_line.hh
index 6d57f47..2bcd6d4 100644
--- a/src/clients/reconcilio/command_line.hh
+++ b/src/clients/reconcilio/command_line.hh
@@ -51,6 +51,8 @@ class CommandLine :
paludis::args::LogLevelArg a_log_level;
paludis::args::SwitchArg a_no_colour;
paludis::args::AliasArg a_no_color;
+ paludis::args::SwitchArg a_force_colour;
+ paludis::args::AliasArg a_force_color;
paludis::args::StringArg a_environment;
paludis::args::SwitchArg a_exact;
paludis::args::StringArg a_resume_command_template;
diff --git a/src/clients/reconcilio/reconcilio.cc b/src/clients/reconcilio/reconcilio.cc
index c54e454..3b17615 100644
--- a/src/clients/reconcilio/reconcilio.cc
+++ b/src/clients/reconcilio/reconcilio.cc
@@ -76,6 +76,7 @@ main(int argc, char *argv[])
Log::get_instance()->set_log_level(CommandLine::get_instance()->a_log_level.option());
set_use_colour(! CommandLine::get_instance()->a_no_colour.specified());
+ set_force_colour(CommandLine::get_instance()->a_force_colour.specified());
std::string paludis_command("paludis");
@@ -93,6 +94,9 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_no_color.specified())
paludis_command.append(" --" + CommandLine::get_instance()->a_no_color.long_name());
+ if (CommandLine::get_instance()->a_force_color.specified())
+ paludis_command.append(" --" + CommandLine::get_instance()->a_force_color.long_name());
+
paludis_command.append(CommandLine::get_instance()->install_args.paludis_command_fragment());
paludis_command.append(CommandLine::get_instance()->dl_args.paludis_command_fragment());
diff --git a/src/output/colour.cc b/src/output/colour.cc
index 0e3a25e..150e9d0 100644
--- a/src/output/colour.cc
+++ b/src/output/colour.cc
@@ -24,6 +24,7 @@
namespace
{
static bool can_use_colour = true;
+ static bool force_colour = false;
}
bool
@@ -32,6 +33,9 @@ use_colour()
if (! can_use_colour)
return false;
+ if (force_colour)
+ return true;
+
static bool result(
(1 == isatty(1)) &&
(0 != paludis::getenv_with_default("TERM", "").compare(0, 4, "dumb")));
@@ -45,6 +49,12 @@ set_use_colour(const bool value)
can_use_colour = value;
}
+void
+set_force_colour(const bool value)
+{
+ force_colour = value;
+}
+
bool
use_xterm_titles()
{
diff --git a/src/output/colour.hh b/src/output/colour.hh
index ffd74f6..51f65a1 100644
--- a/src/output/colour.hh
+++ b/src/output/colour.hh
@@ -81,6 +81,7 @@ enum Colour
bool PALUDIS_VISIBLE use_colour();
void PALUDIS_VISIBLE set_use_colour(const bool value);
+void PALUDIS_VISIBLE set_force_colour(const bool value);
bool PALUDIS_VISIBLE use_xterm_titles() PALUDIS_ATTRIBUTE((pure));
template <typename T_>