#include <paludis/paludis.hh>
#include <iostream>
#include <cstdlib>
using namespace examples;
using std::cout;
using std::endl;
namespace
{
std::shared_ptr<OutputManager> make_standard_output_manager(
const Action &)
{
return std::make_shared<StandardOutputManager>();
}
WantPhase want_all_phases(const std::string &)
{
return wp_yes;
}
}
int main(int argc, char * argv[])
{
int exit_status(0);
try
{
"example_action", "EXAMPLE_ACTION_OPTIONS", "EXAMPLE_ACTION_CMDLINE");
for (const auto & id : *ids)
{
if (! id->supports_action(supports_fetch_action))
{
cout << "ID '" << *id << "' does not support the fetch action." << endl;
}
else
{
cout << "ID '" << *id << "' supports the fetch action, trying to fetch:" << endl;
FetchAction fetch_action(make_named_values<FetchActionOptions>(
n::cross_compile_host() = "",
n::errors() = failures,
n::exclude_unmirrorable() = false,
n::fetch_parts() = FetchParts() + fp_regulars + fp_extras,
n::ignore_not_in_manifest() = false,
n::ignore_unfetched() = false,
n::make_output_manager() = &make_standard_output_manager,
n::safe_resume() = true,
n::tool_prefix() = "",
n::want_phase() = &want_all_phases
));
try
{
id->perform_action(fetch_action);
}
{
exit_status |= 1;
cout << "Caught FetchActionError, with the following details:" << endl;
for (const auto & failure : *failures)
{
cout << " * File '" << failure.target_file() << "': ";
bool need_comma(false);
if (failure.requires_manual_fetching())
{
cout << "requires manual fetching";
need_comma = true;
}
if (failure.failed_automatic_fetching())
{
if (need_comma)
cout << ", ";
cout << "failed automatic fetching";
need_comma = true;
}
if (! failure.failed_integrity_checks().empty())
{
if (need_comma)
cout << ", ";
cout << "failed integrity checks: " << failure.failed_integrity_checks();
need_comma = true;
}
}
cout << endl;
}
}
cout << endl;
}
}
{
cout << endl;
cout << "Unhandled exception:" << endl
return EXIT_FAILURE;
}
catch (const std::exception & e)
{
cout << endl;
cout << "Unhandled exception:" << endl
<< " * " << e.what() << endl;
return EXIT_FAILURE;
}
catch (...)
{
cout << endl;
cout << "Unhandled exception:" << endl
<< " * Unknown exception type. Ouch..." << endl;
return EXIT_FAILURE;
}
return exit_status;
}
Definition exception.hh:77
std::string backtrace(const std::string &delim) const
const char * what() const noexcept override
const std::string & message() const noexcept
Definition sequence.hh:51
static CommandLine * get_instance() PALUDIS_ATTRIBUTE((warn_unused_result))
Definition generator.hh:179
Definition selection.hh:172
Definition about_metadata-fwd.hh:24