aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-14 01:43:38 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-14 01:43:38 +0000
commitf3b26291b12447658d69008593f09487f57a7797 (patch)
tree0c6debe25f5b6b334380b8aa150ea76dc397f9c1
parenteb6396007efea32c14dbe4ced7dd26bf274e18a8 (diff)
downloadpaludis-f3b26291b12447658d69008593f09487f57a7797.tar.gz
paludis-f3b26291b12447658d69008593f09487f57a7797.tar.xz
Only use PALUDIS_OPTIONS for paludis. Add ADJUTRIX_OPTIONS etc for other clients. From Marco Matthies
-rw-r--r--paludis/args/args_handler.cc8
-rw-r--r--paludis/args/args_handler.hh8
-rw-r--r--src/adjutrix/Makefile.am2
-rw-r--r--src/adjutrix/adjutrix.cc2
-rwxr-xr-xsrc/adjutrix/args_from_environment_TEST4
-rw-r--r--src/adjutrix/command_line.cc5
-rw-r--r--src/gtkpaludis/command_line.cc1
-rw-r--r--src/gtkpaludis/gtkpaludis.cc2
-rw-r--r--src/paludis/Makefile.am2
-rwxr-xr-xsrc/paludis/args_from_environment_TEST3
-rw-r--r--src/paludis/command_line.cc11
-rw-r--r--src/paludis/paludis.cc2
-rw-r--r--src/qualudis/qualudis.cc2
-rw-r--r--src/qualudis/qualudis_command_line.cc1
14 files changed, 34 insertions, 19 deletions
diff --git a/paludis/args/args_handler.cc b/paludis/args/args_handler.cc
index d7ab67c..04e7e6a 100644
--- a/paludis/args/args_handler.cc
+++ b/paludis/args/args_handler.cc
@@ -70,7 +70,7 @@ ArgsHandler::add_usage_line(const std::string & l)
}
void
-ArgsHandler::add_enviromnent_variable(const std::string & e, const std::string & desc)
+ArgsHandler::add_environment_variable(const std::string & e, const std::string & desc)
{
_imp->environment_lines.push_back(std::make_pair(e, desc));
}
@@ -83,11 +83,13 @@ ArgsHandler::add(ArgsGroup * const g)
}
void
-ArgsHandler::run(const int argc, const char * const * const argv)
+ArgsHandler::run(const int argc, const char * const * const argv, const std::string & env_var)
{
std::list<std::string> args;
+ std::string env_options;
- std::string env_options = paludis::getenv_with_default("PALUDIS_OPTIONS", "");
+ if (!env_var.empty())
+ env_options = paludis::getenv_with_default(env_var, "");
std::istringstream iss(env_options);
std::string option;
diff --git a/paludis/args/args_handler.hh b/paludis/args/args_handler.hh
index b9538a9..d685d7e 100644
--- a/paludis/args/args_handler.hh
+++ b/paludis/args/args_handler.hh
@@ -61,7 +61,7 @@ namespace paludis
/**
* Add a new environment line.
*/
- void add_enviromnent_variable(const std::string & e, const std::string & desc);
+ void add_environment_variable(const std::string & e, const std::string & desc);
/**
* Add an new ArgsGroup (called by the ArgsGroup constructor).
@@ -84,9 +84,11 @@ namespace paludis
///\}
/**
- * Parse command line arguments.
+ * Parse command line arguments. The last (optional) argument is the name
+ * of an environment variable holding arguments which are prepended to the
+ * command line arguments.
*/
- void run(const int, const char * const * const);
+ void run(const int, const char * const * const, const std::string & env_var = "");
///\name Iterate over our parameters (non - and -- switches and their values)
///\{
diff --git a/src/adjutrix/Makefile.am b/src/adjutrix/Makefile.am
index 7588766..d1e967d 100644
--- a/src/adjutrix/Makefile.am
+++ b/src/adjutrix/Makefile.am
@@ -57,7 +57,7 @@ TESTS_ENVIRONMENT = env \
SYSCONFDIR="$(sysconfdir)" \
bash $(top_srcdir)/test/run_test.sh bash
-TESTS = version_TEST help_TEST find_stable_candidates_TEST
+TESTS = version_TEST help_TEST find_stable_candidates_TEST args_from_environment_TEST
EXTRA_DIST = \
$(man_MANS) \
diff --git a/src/adjutrix/adjutrix.cc b/src/adjutrix/adjutrix.cc
index 2892f6e..4aebee8 100644
--- a/src/adjutrix/adjutrix.cc
+++ b/src/adjutrix/adjutrix.cc
@@ -112,7 +112,7 @@ main(int argc, char *argv[])
try
{
- CommandLine::get_instance()->run(argc, argv);
+ CommandLine::get_instance()->run(argc, argv, "ADJUTRIX_OPTIONS");
set_use_colour(! CommandLine::get_instance()->a_no_color.specified());
if (CommandLine::get_instance()->a_help.specified())
diff --git a/src/adjutrix/args_from_environment_TEST b/src/adjutrix/args_from_environment_TEST
new file mode 100755
index 0000000..00b0489
--- /dev/null
+++ b/src/adjutrix/args_from_environment_TEST
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+ADJUTRIX_OPTIONS=--help ./adjutrix
+
diff --git a/src/adjutrix/command_line.cc b/src/adjutrix/command_line.cc
index c0b5c91..6f1276e 100644
--- a/src/adjutrix/command_line.cc
+++ b/src/adjutrix/command_line.cc
@@ -102,10 +102,11 @@ CommandLine::CommandLine() :
add_usage_line("--version");
add_usage_line("--help");
- add_enviromnent_variable("PALUDIS_EBUILD_DIR", "Where to look for ebuild.bash and related "
+ add_environment_variable("PALUDIS_EBUILD_DIR", "Where to look for ebuild.bash and related "
"utilities.");
- add_enviromnent_variable("PALUDIS_REPOSITORY_SO_DIR", "Where to look for repository .so "
+ add_environment_variable("PALUDIS_REPOSITORY_SO_DIR", "Where to look for repository .so "
"files.");
+ add_environment_variable("ADJUTRIX_OPTIONS", "Default command-line options.");
}
std::string
diff --git a/src/gtkpaludis/command_line.cc b/src/gtkpaludis/command_line.cc
index 72582ea..3016e10 100644
--- a/src/gtkpaludis/command_line.cc
+++ b/src/gtkpaludis/command_line.cc
@@ -43,6 +43,7 @@ CommandLine::CommandLine() :
add_usage_line("[ general options ]");
add_usage_line("--version");
add_usage_line("--help");
+ add_environment_variable("GTKPALUDIS_OPTIONS", "Default command-line options.");
}
std::string
diff --git a/src/gtkpaludis/gtkpaludis.cc b/src/gtkpaludis/gtkpaludis.cc
index 2db954c..5aea6e2 100644
--- a/src/gtkpaludis/gtkpaludis.cc
+++ b/src/gtkpaludis/gtkpaludis.cc
@@ -143,7 +143,7 @@ main(int argc, char * argv[])
{
{
Context context_local("When handling command line:");
- CommandLine::get_instance()->run(argc, argv);
+ CommandLine::get_instance()->run(argc, argv, "GTKPALUDIS_OPTIONS");
if (CommandLine::get_instance()->a_help.specified())
throw DoHelp();
diff --git a/src/paludis/Makefile.am b/src/paludis/Makefile.am
index 2fd2116..7f28e17 100644
--- a/src/paludis/Makefile.am
+++ b/src/paludis/Makefile.am
@@ -62,7 +62,7 @@ TESTS_ENVIRONMENT = env \
TESTS = version_TEST help_TEST list_sync_formats_TEST \
list_repository_formats_TEST list_dep_tag_categories_TEST \
- exception_TEST install_TEST upgrade_TEST
+ exception_TEST install_TEST upgrade_TEST args_from_environment_TEST
EXTRA_DIST = \
$(man_MANS) \
diff --git a/src/paludis/args_from_environment_TEST b/src/paludis/args_from_environment_TEST
new file mode 100755
index 0000000..e700e88
--- /dev/null
+++ b/src/paludis/args_from_environment_TEST
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+PALUDIS_SKIP_CONFIG=yes PALUDIS_OPTIONS=--version ./paludis
diff --git a/src/paludis/command_line.cc b/src/paludis/command_line.cc
index 789fbd6..f0d3853 100644
--- a/src/paludis/command_line.cc
+++ b/src/paludis/command_line.cc
@@ -195,16 +195,17 @@ CommandLine::CommandLine() :
add_usage_line("--list-dep-tag-categories");
add_usage_line("--update-news");
- add_enviromnent_variable("PALUDIS_HOME", "Overrides the home directory used when searching "
+ add_environment_variable("PALUDIS_HOME", "Overrides the home directory used when searching "
"for configuration files etc.");
- add_enviromnent_variable("PALUDIS_NO_GLOBAL_HOOKS", "Don't use global hooks. Mostly for "
+ add_environment_variable("PALUDIS_NO_GLOBAL_HOOKS", "Don't use global hooks. Mostly for "
"internal and test case use.");
- add_enviromnent_variable("PALUDIS_SKIP_CONFIG", "Don't load configuration. Mostly for "
+ add_environment_variable("PALUDIS_SKIP_CONFIG", "Don't load configuration. Mostly for "
"internal and test case use.");
- add_enviromnent_variable("PALUDIS_EBUILD_DIR", "Where to look for ebuild.bash and related "
+ add_environment_variable("PALUDIS_EBUILD_DIR", "Where to look for ebuild.bash and related "
"utilities.");
- add_enviromnent_variable("PALUDIS_REPOSITORY_SO_DIR", "Where to look for repository .so "
+ add_environment_variable("PALUDIS_REPOSITORY_SO_DIR", "Where to look for repository .so "
"files.");
+ add_environment_variable("PALUDIS_OPTIONS", "Default command-line options.");
}
std::string
diff --git a/src/paludis/paludis.cc b/src/paludis/paludis.cc
index 939f29f..fd9c4fa 100644
--- a/src/paludis/paludis.cc
+++ b/src/paludis/paludis.cc
@@ -133,7 +133,7 @@ main(int argc, char *argv[])
try
{
- CommandLine::get_instance()->run(argc, argv);
+ CommandLine::get_instance()->run(argc, argv, "PALUDIS_OPTIONS");
set_use_colour(! CommandLine::get_instance()->a_no_color.specified());
if (CommandLine::get_instance()->a_help.specified())
diff --git a/src/qualudis/qualudis.cc b/src/qualudis/qualudis.cc
index fa53ed9..695a751 100644
--- a/src/qualudis/qualudis.cc
+++ b/src/qualudis/qualudis.cc
@@ -460,7 +460,7 @@ int main(int argc, char *argv[])
try
{
- QualudisCommandLine::get_instance()->run(argc, argv);
+ QualudisCommandLine::get_instance()->run(argc, argv, "QUALUDIS_OPTIONS");
if (QualudisCommandLine::get_instance()->a_help.specified())
throw DoHelp();
diff --git a/src/qualudis/qualudis_command_line.cc b/src/qualudis/qualudis_command_line.cc
index 4869249..0363ecb 100644
--- a/src/qualudis/qualudis_command_line.cc
+++ b/src/qualudis/qualudis_command_line.cc
@@ -53,6 +53,7 @@ QualudisCommandLine::QualudisCommandLine() :
message_level(paludis::qa::qal_info)
{
add_usage_line("[ options ] [ directories ... ]");
+ add_environment_variable("QUALUDIS_OPTIONS", "Default command-line options.");
}
QualudisCommandLine::~QualudisCommandLine()