aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-31 16:43:33 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-31 16:43:33 +0100
commit972f9224e48e006762892c4a35b4f0788ddadda3 (patch)
treecfae0158d88d9a5e8d143c7366311999fcb11b57
parent03d686de567d9ca698de606086b4d12adfbd5580 (diff)
downloadpaludis-972f9224e48e006762892c4a35b4f0788ddadda3.tar.gz
paludis-972f9224e48e006762892c4a35b4f0788ddadda3.tar.xz
cave import/fix-linkage blah -- resolve options
Fixes: ticket:863
-rw-r--r--paludis/args/args_handler.cc17
-rw-r--r--paludis/args/args_handler.hh11
-rw-r--r--paludis/args/args_handler.se1
-rw-r--r--src/clients/cave/cmd_fix_linkage.cc74
-rw-r--r--src/clients/cave/cmd_import.cc73
5 files changed, 147 insertions, 29 deletions
diff --git a/paludis/args/args_handler.cc b/paludis/args/args_handler.cc
index 8f8ed4c..683a9ba 100644
--- a/paludis/args/args_handler.cc
+++ b/paludis/args/args_handler.cc
@@ -58,11 +58,17 @@ namespace paludis
std::list<std::pair<std::string, std::string> > example_lines;
std::list<std::string> notes;
std::list<std::string> descriptions;
+ std::tr1::shared_ptr<Sequence<std::string> > separate_after_dashes_args;
std::map<std::string, ArgsOption *> longopts;
std::map<char, ArgsOption *> shortopts;
std::tr1::shared_ptr<ArgsSection> main_options_section;
+
+ Implementation() :
+ separate_after_dashes_args(new Sequence<std::string>)
+ {
+ }
};
template <>
@@ -189,6 +195,11 @@ ArgsHandler::run(
if (arg == "--")
{
++argit;
+
+ if (options[aho_separate_after_dashes])
+ for ( ; argit != arge ; ++argit)
+ _imp->separate_after_dashes_args->push_back(*argit);
+
break;
}
else if (0 == arg.compare(0, 2, "--"))
@@ -425,6 +436,12 @@ ArgsHandler::add_description_line(const std::string & e)
_imp->descriptions.push_back(e);
}
+const std::tr1::shared_ptr<const Sequence<std::string> >
+ArgsHandler::separate_after_dashes_args() const
+{
+ return _imp->separate_after_dashes_args;
+}
+
template class WrappedForwardIterator<ArgsHandler::ParametersConstIteratorTag, const std::string>;
template class WrappedForwardIterator<ArgsHandler::UsageLineConstIteratorTag, const std::string>;
template class WrappedForwardIterator<ArgsHandler::EnvironmentLineConstIteratorTag,
diff --git a/paludis/args/args_handler.hh b/paludis/args/args_handler.hh
index b247206..af84ef8 100644
--- a/paludis/args/args_handler.hh
+++ b/paludis/args/args_handler.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
*
* 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
@@ -126,6 +126,15 @@ namespace paludis
bool empty() const;
+ /**
+ * If aho_separate_after_dashes, everything after a -- goes
+ * here.
+ *
+ * \since 0.47
+ */
+ const std::tr1::shared_ptr<const Sequence<std::string> > separate_after_dashes_args() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
///\}
/**
diff --git a/paludis/args/args_handler.se b/paludis/args/args_handler.se
index 029e6eb..70c088a 100644
--- a/paludis/args/args_handler.se
+++ b/paludis/args/args_handler.se
@@ -8,5 +8,6 @@ make_enum_ArgsHandlerOption()
namespace paludis::args
key aho_stop_on_first_parameter "Stop on the first parameter encountered"
+ key aho_separate_after_dashes "\since 0.47 Collect everything after a -- separately"
}
diff --git a/src/clients/cave/cmd_fix_linkage.cc b/src/clients/cave/cmd_fix_linkage.cc
index 5220df2..3969254 100644
--- a/src/clients/cave/cmd_fix_linkage.cc
+++ b/src/clients/cave/cmd_fix_linkage.cc
@@ -55,42 +55,75 @@ namespace
struct FixLinkageCommandLine :
CaveCommandCommandLine
{
+ args::ArgsGroup g_execution_options;
+ args::SwitchArg a_execute;
+
args::ArgsGroup g_linkage_options;
args::StringArg a_library;
args::SwitchArg a_exact;
+ FixLinkageCommandLine() :
+ g_execution_options(main_options_section(), "Execution Options", "Control execution."),
+ a_execute(&g_execution_options, "execute", 'x', "Execute the suggested actions", true),
+ g_linkage_options(main_options_section(), "Linkage options", "Options relating to linkage"),
+ a_library(&g_linkage_options, "library", 'l', "Only rebuild packages linked against this library, even if it exists"),
+ a_exact(&g_linkage_options, "exact", 'e', "Rebuild the same package version that is currently installed", true)
+ {
+ add_usage_line("[ -x|--execute ] [ --library foo.so.1 ] [ -- options for 'cave resolve' ]");
+
+ add_note("This command uses the same underlying logic as 'cave resolve'. Any option that is "
+ "valid for 'cave resolve' may be passed as a parameter following a '--'. For example, "
+ "'cave fix-linkage --library foo.so.1 cat/pkg -- --lazy' may be useful. As a "
+ "special case, '--execute' does not require a '--'.");
+ }
+
+ std::string app_name() const
+ {
+ return "cave fix-linkage";
+ }
+
+ std::string app_synopsis() const
+ {
+ return "Identify packages with broken linkage that can be fixed by rebuilds.";
+ }
+
+ std::string app_description() const
+ {
+ return "Identifies packages with broken linkage that can be fixed by rebuilds. "
+ "If instructed, then executes the relevant install and uninstall actions to "
+ "do said fixing.";
+ }
+ };
+
+ struct OptionsForResolve :
+ args::ArgsHandler
+ {
ResolveCommandLineResolutionOptions resolution_options;
ResolveCommandLineExecutionOptions execution_options;
ResolveCommandLineDisplayOptions display_options;
ResolveCommandLineProgramOptions program_options;
- FixLinkageCommandLine() :
- g_linkage_options(main_options_section(), "Linkage options", "Options relating to linkage"),
- a_library(&g_linkage_options, "library", '\0', "Only rebuild packages linked against this library, even if it exists"),
- a_exact(&g_linkage_options, "exact", '\0', "Rebuild the same package version that is currently installed", true),
+ OptionsForResolve() :
resolution_options(this),
execution_options(this),
display_options(this),
program_options(this)
{
- add_usage_line("[ -x|--execute ] [ --library foo.so.1 ]");
}
std::string app_name() const
{
- return "cave fix-linkage";
+ return "";
}
std::string app_synopsis() const
{
- return "Identify packages with broken linkage that can be fixed by rebuilds.";
+ return "";
}
std::string app_description() const
{
- return "Identifies packages with broken linkage that can be fixed by rebuilds. "
- "If instructed, then executes the relevant install and uninstall actions to "
- "do said fixing.";
+ return "";
}
};
}
@@ -102,7 +135,12 @@ FixLinkageCommand::run(
)
{
FixLinkageCommandLine cmdline;
- cmdline.run(args, "CAVE", "CAVE_FIX_LINKAGE_OPTIONS", "CAVE_FIX_LINKAGE_CMDLINE");
+ OptionsForResolve resolve_cmdline;
+
+ cmdline.run(args, "CAVE", "CAVE_FIX_LINKAGE_OPTIONS", "CAVE_FIX_LINKAGE_CMDLINE",
+ args::ArgsHandlerOptions() + args::aho_separate_after_dashes);
+ resolve_cmdline.run(cmdline.separate_after_dashes_args(),
+ "CAVE", "CAVE_RESOLVE_OPTIONS", "CAVE_RESOLVE_CMDLINE");
if (cmdline.a_help.specified())
{
@@ -113,8 +151,11 @@ FixLinkageCommand::run(
if (cmdline.begin_parameters() != cmdline.end_parameters())
throw args::DoHelp("fix-linkage takes no parameters");
- cmdline.resolution_options.apply_shortcuts();
- cmdline.resolution_options.verify(env);
+ resolve_cmdline.resolution_options.apply_shortcuts();
+ resolve_cmdline.resolution_options.verify(env);
+
+ if (cmdline.a_execute.specified())
+ resolve_cmdline.resolution_options.a_execute.set_specified(true);
std::string library(cmdline.a_library.argument());
if (library.empty())
@@ -191,8 +232,11 @@ FixLinkageCommand::run(
}
}
- return resolve_common(env, cmdline.resolution_options, cmdline.execution_options, cmdline.display_options,
- cmdline.program_options, make_null_shared_ptr(), targets);
+ return resolve_common(env, resolve_cmdline.resolution_options,
+ resolve_cmdline.execution_options,
+ resolve_cmdline.display_options,
+ resolve_cmdline.program_options,
+ make_null_shared_ptr(), targets);
}
std::tr1::shared_ptr<args::ArgsHandler>
diff --git a/src/clients/cave/cmd_import.cc b/src/clients/cave/cmd_import.cc
index 767b820..a7e264d 100644
--- a/src/clients/cave/cmd_import.cc
+++ b/src/clients/cave/cmd_import.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* 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
@@ -74,6 +74,9 @@ namespace
"is provided, as is content tracking for installed files.";
}
+ args::ArgsGroup g_execution_options;
+ args::SwitchArg a_execute;
+
args::ArgsGroup g_contents_options;
args::StringArg a_location;
args::StringArg a_install_under;
@@ -85,12 +88,10 @@ namespace
args::StringSetArg a_run_dependency;
args::StringArg a_preserve_metadata;
- ResolveCommandLineResolutionOptions resolution_options;
- ResolveCommandLineExecutionOptions execution_options;
- ResolveCommandLineDisplayOptions display_options;
- ResolveCommandLineProgramOptions program_options;
-
ImportCommandLine() :
+ g_execution_options(main_options_section(), "Execution Options", "Control execution."),
+ a_execute(&g_execution_options, "execute", 'x', "Execute the suggested actions", true),
+
g_contents_options(main_options_section(), "Contents Options",
"Options controlling the content to install"),
a_location(&g_contents_options, "location", 'l',
@@ -110,13 +111,47 @@ namespace
"Specify a run dependency. May be specified multiple times."),
a_preserve_metadata(&g_metadata_options, "preserve-metadata", 'P',
"If replacing a package previously installed using this command, copy its description "
- "and dependencies"),
+ "and dependencies")
+ {
+ add_usage_line("[ --location blah ] cat/pkg [ version ] [ slot ] "
+ "[ --execute ] [ -- options for 'cave resolve' ]");
+
+ add_note("This command uses the same underlying logic as 'cave resolve'. Any option that is "
+ "valid for 'cave resolve' may be passed as a parameter following a '--'. For example, "
+ "'cave import cat/pkg --build-dependency some/dep -- --lazy' may be useful. As a "
+ "special case, '--execute' does not require a '--'.");
+ }
+ };
+
+ struct OptionsForResolve :
+ args::ArgsHandler
+ {
+ ResolveCommandLineResolutionOptions resolution_options;
+ ResolveCommandLineExecutionOptions execution_options;
+ ResolveCommandLineDisplayOptions display_options;
+ ResolveCommandLineProgramOptions program_options;
+
+ OptionsForResolve() :
resolution_options(this),
execution_options(this),
display_options(this),
program_options(this)
{
- add_usage_line("[ --location blah ] cat/pkg [ version ] [ slot ]");
+ }
+
+ std::string app_name() const
+ {
+ return "";
+ }
+
+ std::string app_synopsis() const
+ {
+ return "";
+ }
+
+ std::string app_description() const
+ {
+ return "";
}
};
@@ -138,7 +173,12 @@ ImportCommand::run(
)
{
ImportCommandLine cmdline;
- cmdline.run(args, "CAVE", "CAVE_IMPORT_OPTIONS", "CAVE_IMPORT_CMDLINE");
+ OptionsForResolve resolve_cmdline;
+
+ cmdline.run(args, "CAVE", "CAVE_IMPORT_OPTIONS", "CAVE_IMPORT_CMDLINE",
+ args::ArgsHandlerOptions() + args::aho_separate_after_dashes);
+ resolve_cmdline.run(cmdline.separate_after_dashes_args(),
+ "CAVE", "CAVE_RESOLVE_OPTIONS", "CAVE_RESOLVE_CMDLINE");
if (cmdline.a_help.specified())
{
@@ -224,14 +264,21 @@ ImportCommand::run(
throw InternalError(PALUDIS_HERE, "ids is '" + join(indirect_iterator(ids->begin()), indirect_iterator(
ids->end()), " ") + "'");
- cmdline.resolution_options.apply_shortcuts();
- cmdline.resolution_options.verify(env);
+ resolve_cmdline.resolution_options.apply_shortcuts();
+ resolve_cmdline.resolution_options.verify(env);
+
+ if (cmdline.a_execute.specified())
+ resolve_cmdline.resolution_options.a_execute.set_specified(true);
std::tr1::shared_ptr<Sequence<std::string> > targets(new Sequence<std::string>);
targets->push_back(stringify((*ids->begin())->name()));
- return resolve_common(env, cmdline.resolution_options, cmdline.execution_options, cmdline.display_options,
- cmdline.program_options, keys, targets);
+ return resolve_common(env,
+ resolve_cmdline.resolution_options,
+ resolve_cmdline.execution_options,
+ resolve_cmdline.display_options,
+ resolve_cmdline.program_options,
+ keys, targets);
}
std::tr1::shared_ptr<args::ArgsHandler>