aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-07 18:26:24 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-07 18:26:24 +0000
commitb9c426a147bf0db03cd3c045da4f884f2ea9259f (patch)
tree63e64d199f147390c59d443603c0648b44c8a1c7
parent0b5a7ded3a4dccc7a11c438d43127b37767efc33 (diff)
downloadpaludis-b9c426a147bf0db03cd3c045da4f884f2ea9259f.tar.gz
paludis-b9c426a147bf0db03cd3c045da4f884f2ea9259f.tar.xz
Add --configuration-variable <repo> <var> commandline option
-rw-r--r--src/applets.cc28
-rw-r--r--src/applets.hh3
-rw-r--r--src/command_line.cc2
-rw-r--r--src/command_line.hh3
-rw-r--r--src/paludis.cc10
5 files changed, 46 insertions, 0 deletions
diff --git a/src/applets.cc b/src/applets.cc
index dc5109e..b9ddc07 100644
--- a/src/applets.cc
+++ b/src/applets.cc
@@ -112,6 +112,34 @@ int do_environment_variable()
return return_code;
}
+int do_configuration_variable()
+{
+ int return_code(0);
+
+ p::Context context("When performing configuration-variable action from command line:");
+ p::Environment * const env(p::DefaultEnvironment::get_instance());
+
+ std::string repo_str(*CommandLine::get_instance()->begin_parameters());
+ std::string var_str(* p::next(CommandLine::get_instance()->begin_parameters()));
+
+ p::RepositoryInfo::ConstPointer info(env->package_database()->fetch_repository(
+ p::RepositoryName(repo_str))->info(false));
+
+ return_code = 1;
+ for (p::RepositoryInfo::SectionIterator s(info->begin_sections()),
+ s_end(info->end_sections()) ; s != s_end ; ++s)
+ for (p::RepositoryInfoSection::KeyValueIterator k(s->begin_kvs()),
+ k_end(s->end_kvs()) ; k != k_end ; ++k)
+ if (var_str == k->first)
+ {
+ std::cout << k->second << std::endl;
+ return_code = 0;
+ break;
+ }
+
+ return return_code;
+}
+
int do_list_repository_formats()
{
int return_code(1);
diff --git a/src/applets.hh b/src/applets.hh
index fc7e21b..33602ce 100644
--- a/src/applets.hh
+++ b/src/applets.hh
@@ -35,6 +35,9 @@ int do_best_version();
/// Handle --environment-variable.
int do_environment_variable();
+/// Handle --configuration-variable.
+int do_configuration_variable();
+
/// Handle --list-repository-formats
int do_list_repository_formats();
diff --git a/src/command_line.cc b/src/command_line.cc
index a8bad65..a8daaf7 100644
--- a/src/command_line.cc
+++ b/src/command_line.cc
@@ -38,6 +38,8 @@ CommandLine::CommandLine() :
a_best_version(&action_args_internal, "best-version", '\0', "Display the best version of the specified atom"),
a_environment_variable(&action_args_internal, "environment-variable", '\0', "Display the value of an environment "
"variable for a particular package"),
+ a_configuration_variable(&action_args_internal, "configuration-variable", '\0', "Display the value of a "
+ "configuration variable for a particular package"),
a_list_repositories(&action_args_internal, "list-repositories", '\0', "List available repositories"),
a_list_categories(&action_args_internal, "list-categories", '\0', "List available categories"),
a_list_packages(&action_args_internal, "list-packages", '\0', "List available packages"),
diff --git a/src/command_line.hh b/src/command_line.hh
index 3f2b3a6..61f88e7 100644
--- a/src/command_line.hh
+++ b/src/command_line.hh
@@ -89,6 +89,9 @@ class CommandLine :
/// --environment-variable
paludis::args::SwitchArg a_environment_variable;
+ /// --configuration-variable
+ paludis::args::SwitchArg a_configuration_variable;
+
/// --list-repositories
paludis::args::SwitchArg a_list_repositories;
diff --git a/src/paludis.cc b/src/paludis.cc
index 9069c0e..0bdc823 100644
--- a/src/paludis.cc
+++ b/src/paludis.cc
@@ -168,6 +168,7 @@ main(int argc, char *argv[])
CommandLine::get_instance()->a_has_version.specified() +
CommandLine::get_instance()->a_update_news.specified() +
CommandLine::get_instance()->a_environment_variable.specified() +
+ CommandLine::get_instance()->a_configuration_variable.specified() +
CommandLine::get_instance()->a_info.specified() +
CommandLine::get_instance()->a_best_version.specified()))
{
@@ -357,6 +358,15 @@ main(int argc, char *argv[])
return do_environment_variable();
}
+ if (CommandLine::get_instance()->a_configuration_variable.specified())
+ {
+ if (2 != std::distance(CommandLine::get_instance()->begin_parameters(),
+ CommandLine::get_instance()->end_parameters()))
+ throw DoHelp("configuration-variable action takes exactly two parameters (depatom var)");
+
+ return do_configuration_variable();
+ }
+
if (CommandLine::get_instance()->a_update_news.specified())
{
if (! CommandLine::get_instance()->empty())