aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-02 17:23:25 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-02 17:23:25 +0100
commitae1d2c5f8cc11ed6579fd45ff034ec2944a86f8c (patch)
tree9fafd1660605e476894b5ea714b281e636383c95
parent9e23047346d2d7f8e3de4aa21e7915158ec1e413 (diff)
downloadpaludis-ae1d2c5f8cc11ed6579fd45ff034ec2944a86f8c.tar.gz
paludis-ae1d2c5f8cc11ed6579fd45ff034ec2944a86f8c.tar.xz
Sectionise resolve cmdline
-rw-r--r--src/clients/cave/cmd_resolve.cc88
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.cc20
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.hh19
-rw-r--r--src/clients/cave/cmd_resolve_display_explanations.cc5
-rw-r--r--src/clients/cave/cmd_resolve_dump.cc4
5 files changed, 77 insertions, 59 deletions
diff --git a/src/clients/cave/cmd_resolve.cc b/src/clients/cave/cmd_resolve.cc
index c9c6fa2..0a2017d 100644
--- a/src/clients/cave/cmd_resolve.cc
+++ b/src/clients/cave/cmd_resolve.cc
@@ -134,12 +134,12 @@ namespace
UseInstalled visit(const DependencyReason &) const
{
- return use_installed_from_cmdline(cmdline.a_keep, false);
+ return use_installed_from_cmdline(cmdline.resolution_options.a_keep, false);
}
UseInstalled visit(const TargetReason &) const
{
- return use_installed_from_cmdline(cmdline.a_keep_targets, from_set);
+ return use_installed_from_cmdline(cmdline.resolution_options.a_keep_targets, from_set);
}
UseInstalled visit(const PresetReason &) const
@@ -165,17 +165,17 @@ namespace
int reinstall_scm_days(const ResolveCommandLine & cmdline)
{
- if (cmdline.a_reinstall_scm.argument() == "always")
+ if (cmdline.resolution_options.a_reinstall_scm.argument() == "always")
return 0;
- else if (cmdline.a_reinstall_scm.argument() == "daily")
+ else if (cmdline.resolution_options.a_reinstall_scm.argument() == "daily")
return 1;
- else if (cmdline.a_reinstall_scm.argument() == "weekly")
+ else if (cmdline.resolution_options.a_reinstall_scm.argument() == "weekly")
return 7;
- else if (cmdline.a_reinstall_scm.argument() == "never")
+ else if (cmdline.resolution_options.a_reinstall_scm.argument() == "never")
return -1;
else
- throw args::DoHelp("Don't understand argument '" + cmdline.a_reinstall_scm.argument() + "' to '--"
- + cmdline.a_reinstall_scm.long_name() + "'");
+ throw args::DoHelp("Don't understand argument '" + cmdline.resolution_options.a_reinstall_scm.argument() + "' to '--"
+ + cmdline.resolution_options.a_reinstall_scm.long_name() + "'");
}
bool is_scm_name(const QualifiedPackageName & n)
@@ -363,7 +363,7 @@ namespace
i != i_end ; ++i)
installed.push_back(QPN_S(*i));
- const args::EnumArg & arg(is_target(reason) ? cmdline.a_target_slots : cmdline.a_slots);
+ const args::EnumArg & arg(is_target(reason) ? cmdline.resolution_options.a_target_slots : cmdline.resolution_options.a_slots);
if (! best)
std::copy(installed.begin(), installed.end(), result->back_inserter());
@@ -501,10 +501,10 @@ namespace
if (resolution->decision()->is_installed())
{
- if (! cmdline.a_follow_installed_build_dependencies.specified())
+ if (! cmdline.resolution_options.a_follow_installed_build_dependencies.specified())
if (is_just_build_dep(dep))
return false;
- if (cmdline.a_ignore_installed_dependencies.specified())
+ if (cmdline.resolution_options.a_ignore_installed_dependencies.specified())
if (! is_compiled_against_dep(dep))
return false;
}
@@ -535,46 +535,48 @@ ResolveCommand::run(
return EXIT_SUCCESS;
}
- if (cmdline.a_lazy.specified() + cmdline.a_complete.specified() + cmdline.a_everything.specified() > 1)
- throw args::DoHelp("At most one of '--" + cmdline.a_lazy.long_name() + "', '--" + cmdline.a_complete.long_name()
- + "' or '--" + cmdline.a_everything.long_name() + "' may be specified");
+ if (cmdline.resolution_options.a_lazy.specified() +
+ cmdline.resolution_options.a_complete.specified() +
+ cmdline.resolution_options.a_everything.specified() > 1)
+ throw args::DoHelp("At most one of '--" + cmdline.resolution_options.a_lazy.long_name() + "', '--" + cmdline.resolution_options.a_complete.long_name()
+ + "' or '--" + cmdline.resolution_options.a_everything.long_name() + "' may be specified");
- if (cmdline.a_lazy.specified())
+ if (cmdline.resolution_options.a_lazy.specified())
{
- if (! cmdline.a_target_slots.specified())
- cmdline.a_target_slots.set_argument("best");
- if (! cmdline.a_slots.specified())
- cmdline.a_slots.set_argument("best");
- if (! cmdline.a_reinstall_scm.specified())
- cmdline.a_reinstall_scm.set_argument("never");
- if (! cmdline.a_ignore_installed_dependencies.specified())
- cmdline.a_ignore_installed_dependencies.set_specified(true);
+ if (! cmdline.resolution_options.a_target_slots.specified())
+ cmdline.resolution_options.a_target_slots.set_argument("best");
+ if (! cmdline.resolution_options.a_slots.specified())
+ cmdline.resolution_options.a_slots.set_argument("best");
+ if (! cmdline.resolution_options.a_reinstall_scm.specified())
+ cmdline.resolution_options.a_reinstall_scm.set_argument("never");
+ if (! cmdline.resolution_options.a_ignore_installed_dependencies.specified())
+ cmdline.resolution_options.a_ignore_installed_dependencies.set_specified(true);
}
- if (cmdline.a_complete.specified())
+ if (cmdline.resolution_options.a_complete.specified())
{
- if (! cmdline.a_keep.specified())
- cmdline.a_keep.set_argument("if-same");
- if (! cmdline.a_target_slots.specified())
- cmdline.a_target_slots.set_argument("all");
- if (! cmdline.a_slots.specified())
- cmdline.a_slots.set_argument("all");
- if (! cmdline.a_follow_installed_build_dependencies.specified())
- cmdline.a_follow_installed_build_dependencies.set_specified(true);
+ if (! cmdline.resolution_options.a_keep.specified())
+ cmdline.resolution_options.a_keep.set_argument("if-same");
+ if (! cmdline.resolution_options.a_target_slots.specified())
+ cmdline.resolution_options.a_target_slots.set_argument("all");
+ if (! cmdline.resolution_options.a_slots.specified())
+ cmdline.resolution_options.a_slots.set_argument("all");
+ if (! cmdline.resolution_options.a_follow_installed_build_dependencies.specified())
+ cmdline.resolution_options.a_follow_installed_build_dependencies.set_specified(true);
}
- if (cmdline.a_everything.specified())
+ if (cmdline.resolution_options.a_everything.specified())
{
- if (! cmdline.a_keep.specified())
- cmdline.a_keep.set_argument("if-transient");
- if (! cmdline.a_keep_targets.specified())
- cmdline.a_keep_targets.set_argument("if-transient");
- if (! cmdline.a_target_slots.specified())
- cmdline.a_target_slots.set_argument("all");
- if (! cmdline.a_slots.specified())
- cmdline.a_slots.set_argument("all");
- if (! cmdline.a_follow_installed_build_dependencies.specified())
- cmdline.a_follow_installed_build_dependencies.set_specified(true);
+ if (! cmdline.resolution_options.a_keep.specified())
+ cmdline.resolution_options.a_keep.set_argument("if-transient");
+ if (! cmdline.resolution_options.a_keep_targets.specified())
+ cmdline.resolution_options.a_keep_targets.set_argument("if-transient");
+ if (! cmdline.resolution_options.a_target_slots.specified())
+ cmdline.resolution_options.a_target_slots.set_argument("all");
+ if (! cmdline.resolution_options.a_slots.specified())
+ cmdline.resolution_options.a_slots.set_argument("all");
+ if (! cmdline.resolution_options.a_follow_installed_build_dependencies.specified())
+ cmdline.resolution_options.a_follow_installed_build_dependencies.set_specified(true);
}
int retcode(0);
diff --git a/src/clients/cave/cmd_resolve_cmdline.cc b/src/clients/cave/cmd_resolve_cmdline.cc
index cbec80f..e5905d6 100644
--- a/src/clients/cave/cmd_resolve_cmdline.cc
+++ b/src/clients/cave/cmd_resolve_cmdline.cc
@@ -22,12 +22,13 @@
using namespace paludis;
using namespace cave;
-ResolveCommandLine::ResolveCommandLine() :
+ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::ArgsHandler * const h) :
+ ArgsSection(h, "Resolution Options"),
// g_execution_options(this, "Execution Options", "Control execution."),
// a_execute(&g_execution_options, "execute", 'x', "Execute the suggested actions", true),
// a_preserve_world(&g_execution_options, "preserve-world", '1', "Do not modify the 'world' set", true),
//
- g_convenience_options(main_options_section(), "Convenience Options", "Broad behaviour options."),
+ g_convenience_options(this, "Convenience Options", "Broad behaviour options."),
a_lazy(&g_convenience_options, "lazy", 'z', "Do as little work as possible.", true),
a_complete(&g_convenience_options, "complete", 'c', "Do all optional work.", true),
a_everything(&g_convenience_options, "everything", 'e', "Do all optional work, and also reinstall", true),
@@ -77,7 +78,7 @@ ResolveCommandLine::ResolveCommandLine() :
// "new"
// ),
- g_explanations(main_options_section(), "Explanations", "Options requesting the resolver explain a particular decision "
+ g_explanations(this, "Explanations", "Options requesting the resolver explain a particular decision "
"that it made"),
a_explain(&g_explanations, "explain", '\0', "Explain why the resolver made a particular decision. The "
"argument is a package dependency specification, so --explain dev-libs/boost or --explain qt:3"
@@ -97,7 +98,7 @@ ResolveCommandLine::ResolveCommandLine() :
// ("last", "Only the last package on the list"),
// "all"),
//
- g_keep_options(main_options_section(), "Reinstall Options", "Control whether installed packages are kept."),
+ g_keep_options(this, "Reinstall Options", "Control whether installed packages are kept."),
a_keep_targets(&g_keep_options, "keep-targets", 'K',
"Select whether to keep target packages",
args::EnumArg::EnumArgOptions
@@ -136,7 +137,7 @@ ResolveCommandLine::ResolveCommandLine() :
// a_reinstall_for_removals(&g_reinstall_options, "reinstall-for-removals", '\0',
// "Select whether to rebuild packages if rebuilding would avoid an unsafe removal", true),
//
- g_slot_options(main_options_section(), "Slot Options", "Control which slots are considered."),
+ g_slot_options(this, "Slot Options", "Control which slots are considered."),
a_target_slots(&g_slot_options, "target-slots", 'S',
"Which slots to consider for targets",
args::EnumArg::EnumArgOptions
@@ -164,7 +165,7 @@ ResolveCommandLine::ResolveCommandLine() :
"best-or-installed"
),
- g_dependency_options(main_options_section(), "Dependency Options", "Control which dependencies are followed."),
+ g_dependency_options(this, "Dependency Options", "Control which dependencies are followed."),
a_follow_installed_build_dependencies(&g_dependency_options, "follow-installed-build-dependencies", 'D',
"Follow build dependencies for installed packages (default if --complete or --everything)", true),
a_ignore_installed_dependencies(&g_dependency_options, "ignore-installed-dependencies", 'd',
@@ -217,12 +218,17 @@ ResolveCommandLine::ResolveCommandLine() :
// a_install_to_chroot(&g_destination_options, "install-to-chroot", '\0', "Install packages to the environment-configured chroot", true),
// a_install_to_root(&g_destination_options, "install-to-root", '\0', "Install packages to /", true),
- g_dump_options(main_options_section(), "Dump Options", "Dump the resolver's state to stdout after completion, or when an "
+ g_dump_options(this, "Dump Options", "Dump the resolver's state to stdout after completion, or when an "
"error occurs. For debugging purposes; produces rather a lot of noise."),
a_dump(&g_dump_options, "dump", '\0', "Dump debug output", true),
a_dump_dependencies(&g_dump_options, "dump-dependencies", '\0', "If dumping, also dump the "
"sanitised dependencies selected for every package" , true)
{
+}
+
+ResolveCommandLine::ResolveCommandLine() :
+ resolution_options(this)
+{
add_usage_line("[ -x|--execute ] [ -z|--lazy or -c|--complete or -e|--everything ] spec ...");
add_usage_line("[ -x|--execute ] [ -z|--lazy or -c|--complete or -e|--everything ] set");
}
diff --git a/src/clients/cave/cmd_resolve_cmdline.hh b/src/clients/cave/cmd_resolve_cmdline.hh
index 366982b..0752efb 100644
--- a/src/clients/cave/cmd_resolve_cmdline.hh
+++ b/src/clients/cave/cmd_resolve_cmdline.hh
@@ -26,12 +26,10 @@ namespace paludis
{
namespace cave
{
- struct ResolveCommandLine :
- CaveCommandCommandLine
+ struct ResolveCommandLineResolutionOptions :
+ args::ArgsSection
{
- virtual std::string app_name() const;
- virtual std::string app_synopsis() const;
- virtual std::string app_description() const;
+ ResolveCommandLineResolutionOptions(args::ArgsHandler * const);
// args::ArgsGroup g_execution_options;
// args::SwitchArg a_execute;
@@ -118,7 +116,18 @@ namespace paludis
args::SwitchArg a_dump;
args::SwitchArg a_dump_dependencies;
+ };
+
+ struct ResolveCommandLine :
+ CaveCommandCommandLine
+ {
+ virtual std::string app_name() const;
+ virtual std::string app_synopsis() const;
+ virtual std::string app_description() const;
+
ResolveCommandLine();
+
+ ResolveCommandLineResolutionOptions resolution_options;
};
}
}
diff --git a/src/clients/cave/cmd_resolve_display_explanations.cc b/src/clients/cave/cmd_resolve_display_explanations.cc
index 0622d95..1fe68cb 100644
--- a/src/clients/cave/cmd_resolve_display_explanations.cc
+++ b/src/clients/cave/cmd_resolve_display_explanations.cc
@@ -70,12 +70,13 @@ cave::display_explanations(
{
Context context("When displaying explanations:");
- if (cmdline.a_explain.begin_args() == cmdline.a_explain.end_args())
+ if (cmdline.resolution_options.a_explain.begin_args() == cmdline.resolution_options.a_explain.end_args())
return;
std::cout << "Explaining requested decisions:" << std::endl << std::endl;
- for (args::StringSetArg::ConstIterator i(cmdline.a_explain.begin_args()), i_end(cmdline.a_explain.end_args()) ;
+ for (args::StringSetArg::ConstIterator i(cmdline.resolution_options.a_explain.begin_args()),
+ i_end(cmdline.resolution_options.a_explain.end_args()) ;
i != i_end ; ++i)
{
bool any(false);
diff --git a/src/clients/cave/cmd_resolve_dump.cc b/src/clients/cave/cmd_resolve_dump.cc
index e4c5056..951bde2 100644
--- a/src/clients/cave/cmd_resolve_dump.cc
+++ b/src/clients/cave/cmd_resolve_dump.cc
@@ -36,7 +36,7 @@ paludis::cave::dump_if_requested(
{
Context context("When dumping the resolver:");
- if (! cmdline.a_dump.specified())
+ if (! cmdline.resolution_options.a_dump.specified())
return;
std::cout << "Dumping resolutions by QPN:S:" << std::endl << std::endl;
@@ -47,7 +47,7 @@ paludis::cave::dump_if_requested(
{
std::cout << c->first << std::endl;
std::cout << " = " << *c->second << std::endl;
- if (cmdline.a_dump_dependencies.specified() && c->second->sanitised_dependencies())
+ if (cmdline.resolution_options.a_dump_dependencies.specified() && c->second->sanitised_dependencies())
for (SanitisedDependencies::ConstIterator d(c->second->sanitised_dependencies()->begin()),
d_end(c->second->sanitised_dependencies()->end()) ;
d != d_end ; ++d)