aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-27 00:55:46 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-27 00:55:46 +0000
commit5076ab3ba7d5f39197446bfaab27389fce95f6dc (patch)
tree76e6ca16ef43763b74a1224c718fc44a4add04bd
parentc8f9c9d27702d2f40a84210a0cb31edd19489d4a (diff)
downloadpaludis-5076ab3ba7d5f39197446bfaab27389fce95f6dc.tar.gz
paludis-5076ab3ba7d5f39197446bfaab27389fce95f6dc.tar.xz
Set PALUDIS_CLIENT for use in hooks. Fixes: ticket:47
-rw-r--r--paludis/args/args_TEST.cc6
-rw-r--r--paludis/args/args_handler.cc13
-rw-r--r--paludis/args/args_handler.hh18
-rw-r--r--src/clients/adjutrix/adjutrix.cc4
-rw-r--r--src/clients/contrarius/contrarius.cc2
-rw-r--r--src/clients/gtkpaludis/gtkpaludis.cc5
-rw-r--r--src/clients/paludis/paludis.cc2
-rw-r--r--src/clients/qualudis/qualudis.cc3
8 files changed, 37 insertions, 16 deletions
diff --git a/paludis/args/args_TEST.cc b/paludis/args/args_TEST.cc
index 50d1cc2..d7c6de1 100644
--- a/paludis/args/args_TEST.cc
+++ b/paludis/args/args_TEST.cc
@@ -114,7 +114,7 @@ namespace test_cases
const char * args[] = { "program-name", "--other-monkey", "chimp", "--other-baz",
"-fsne", "blah", "7", "three", "--", "--dummy", "one", "two" };
CommandLine c1;
- c1.run(12, args);
+ c1.run(12, args, "", "", "");
TEST_CHECK(c1.arg_foo.specified());
TEST_CHECK(! c1.arg_bar.specified());
TEST_CHECK(c1.arg_baz.specified());
@@ -150,7 +150,7 @@ namespace test_cases
{
const char *args[] = { "program-name", "-e" };
CommandLine c1;
- TEST_CHECK_THROWS(c1.run(2, args), MissingValue);
+ TEST_CHECK_THROWS(c1.run(2, args, "", "", ""), MissingValue);
}
} test_args_no_param;
@@ -166,7 +166,7 @@ namespace test_cases
{
const char *args[] = { "program-name", "--stringset", "one", "-t", "two", "-t", "three", "fnord" };
CommandLine c1;
- c1.run(8, args);
+ c1.run(8, args, "", "", "");
TEST_CHECK(c1.arg_stringset.specified());
TEST_CHECK(std::find(c1.arg_stringset.begin_args(), c1.arg_stringset.end_args(), "one") != c1.arg_stringset.end_args());
TEST_CHECK(std::find(c1.arg_stringset.begin_args(), c1.arg_stringset.end_args(), "two") != c1.arg_stringset.end_args());
diff --git a/paludis/args/args_handler.cc b/paludis/args/args_handler.cc
index 64735b1..6e7f445 100644
--- a/paludis/args/args_handler.cc
+++ b/paludis/args/args_handler.cc
@@ -87,10 +87,21 @@ void
ArgsHandler::run(const int argc, const char * const * const argv, const std::string & env_var,
const std::string & env_prefix)
{
+ run(argc, argv, "", env_var, env_prefix);
+}
+
+void
+ArgsHandler::run(const int argc, const char * const * const argv,
+ const std::string & client,
+ const std::string & env_var,
+ const std::string & env_prefix)
+{
std::list<std::string> args;
std::string env_options;
- if (!env_var.empty())
+ setenv("PALUDIS_CLIENT", client.c_str(), 1);
+
+ if (! env_var.empty())
env_options = paludis::getenv_with_default(env_var, "");
std::istringstream iss(env_options);
diff --git a/paludis/args/args_handler.hh b/paludis/args/args_handler.hh
index 55ae913..4f41157 100644
--- a/paludis/args/args_handler.hh
+++ b/paludis/args/args_handler.hh
@@ -84,13 +84,21 @@ namespace paludis
///\}
/**
- * Parse command line arguments. The third (optional) argument is the name
- * of an environment variable holding arguments which are prepended to the
- * command line arguments. The fourth (optional) argument is used as a prefix
- * to export our command line via the environment.
+ * \deprecated Use the five arg form.
*/
void run(const int, const char * const * const, const std::string & env_var = "",
- const std::string & env_prefix = "");
+ const std::string & env_prefix = "") PALUDIS_ATTRIBUTE((deprecated));
+
+ /**
+ * Parse command line arguments. The third argument is used to
+ * set PALUDIS_CLIENT. The fourth argument is the name of an
+ * environment variable holding arguments which are prepended
+ * to the command line arguments. The fifth argument is used as
+ * a prefix to export our command line via the environment.
+ */
+ void run(const int, const char * const * const,
+ const std::string & client, const std::string & env_var,
+ const std::string & env_prefix);
///\name Iterate over our parameters (non - and -- switches and their values)
///\{
diff --git a/src/clients/adjutrix/adjutrix.cc b/src/clients/adjutrix/adjutrix.cc
index de8f567..b0592d6 100644
--- a/src/clients/adjutrix/adjutrix.cc
+++ b/src/clients/adjutrix/adjutrix.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -114,7 +114,7 @@ main(int argc, char *argv[])
try
{
- CommandLine::get_instance()->run(argc, argv, "ADJUTRIX_OPTIONS");
+ CommandLine::get_instance()->run(argc, argv, "adjutrix", "ADJUTRIX_OPTIONS", "ADJUTRIX_CMDLINE");
set_use_colour(! CommandLine::get_instance()->a_no_color.specified());
if (CommandLine::get_instance()->a_help.specified())
diff --git a/src/clients/contrarius/contrarius.cc b/src/clients/contrarius/contrarius.cc
index 77b764a..0899df4 100644
--- a/src/clients/contrarius/contrarius.cc
+++ b/src/clients/contrarius/contrarius.cc
@@ -48,7 +48,7 @@ int main(int argc, char *argv[])
try
{
- CommandLine::get_instance()->run(argc, argv);
+ CommandLine::get_instance()->run(argc, argv, "contrarius", "CONTRARIUS_OPTIONS", "CONTRARIUS_CMDLINE");
if (CommandLine::get_instance()->a_help.specified())
throw DoHelp();
diff --git a/src/clients/gtkpaludis/gtkpaludis.cc b/src/clients/gtkpaludis/gtkpaludis.cc
index 0dcacbf..b797345 100644
--- a/src/clients/gtkpaludis/gtkpaludis.cc
+++ b/src/clients/gtkpaludis/gtkpaludis.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -143,7 +143,8 @@ main(int argc, char * argv[])
{
{
Context context_local("When handling command line:");
- CommandLine::get_instance()->run(argc, argv, "GTKPALUDIS_OPTIONS");
+ CommandLine::get_instance()->run(argc, argv, "gtkpaludis", "GTKPALUDIS_OPTIONS",
+ "GTKPALUDIS_CMDLINE");
if (CommandLine::get_instance()->a_help.specified())
throw DoHelp();
diff --git a/src/clients/paludis/paludis.cc b/src/clients/paludis/paludis.cc
index bf32fe2..6b3e806 100644
--- a/src/clients/paludis/paludis.cc
+++ b/src/clients/paludis/paludis.cc
@@ -139,7 +139,7 @@ main(int argc, char *argv[])
try
{
- CommandLine::get_instance()->run(argc, argv, "PALUDIS_OPTIONS", "PALUDIS_CMDLINE");
+ CommandLine::get_instance()->run(argc, argv, "paludis", "PALUDIS_OPTIONS", "PALUDIS_CMDLINE");
set_use_colour(! CommandLine::get_instance()->a_no_color.specified());
if (CommandLine::get_instance()->a_help.specified())
diff --git a/src/clients/qualudis/qualudis.cc b/src/clients/qualudis/qualudis.cc
index a7fe5af..980b897 100644
--- a/src/clients/qualudis/qualudis.cc
+++ b/src/clients/qualudis/qualudis.cc
@@ -555,7 +555,8 @@ int main(int argc, char *argv[])
try
{
- QualudisCommandLine::get_instance()->run(argc, argv, "QUALUDIS_OPTIONS");
+ QualudisCommandLine::get_instance()->run(argc, argv, "qualudis", "QUALUDIS_OPTIONS",
+ "QUALUDIS_CMDLINE");
if (QualudisCommandLine::get_instance()->a_help.specified())
throw DoHelp();