#include <paludis/paludis.hh>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <set>
using namespace examples;
using std::cout;
using std::endl;
using std::left;
using std::setw;
using std::hex;
int main(int argc, char * argv[])
{
int exit_status(0);
try
{
"example_package_id", "EXAMPLE_PACKAGE_ID_OPTIONS", "EXAMPLE_PACKAGE_ID_CMDLINE");
for (const auto & id : *ids)
{
cout << *id << ":" << endl;
cout << left << setw(30) << " Name:" << " " << id->name() << endl;
cout << left << setw(30) << " Version:" << " " << id->version() << endl;
cout << left << setw(30) << " Repository Name:" << " " << id->repository_name() << endl;
cout << left << setw(30) << " idcf_full:" << " " << id->canonical_form(idcf_full) << endl;
cout << left << setw(30) << " idcf_version:" << " " << id->canonical_form(idcf_version) << endl;
cout << left << setw(30) << " idcf_no_version:" << " " << id->canonical_form(idcf_no_version) << endl;
cout << left << setw(30) << " idcf_no_name:" << " " << id->canonical_form(idcf_no_name) << endl;
cout << left << setw(30) << " Keys:" << " " << endl;
for (const auto & key : id->metadata())
cout << left << setw(30) << (" " + key->raw_name() + ":") << " " << key->human_name() << endl;
if (id->masked())
{
cout << left << setw(30) << " Masks:" << " " << endl;
for (const auto & mask : id->masks())
cout << left << setw(30) << (
" " +
stringify(mask->key()) +
":") <<
" " << mask->description() << endl;
}
std::set<std::string> actions;
{
if (id->supports_action(install_action))
actions.insert("install");
if (id->supports_action(uninstall_action))
actions.insert("uninstall");
if (id->supports_action(pretend_action))
actions.insert("pretend");
if (id->supports_action(config_action))
actions.insert("config");
if (id->supports_action(fetch_action))
actions.insert("fetch");
if (id->supports_action(info_action))
actions.insert("info");
}
cout << left << setw(30) <<
" Actions:" <<
" " <<
join(actions.begin(), actions.end(),
" ") << endl;
cout << left << setw(30) << " extra_hash_value:" << " " << "0x" << hex << id->extra_hash_value() << 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
static CommandLine * get_instance() PALUDIS_ATTRIBUTE((warn_unused_result))
Definition generator.hh:179
Definition selection.hh:172
T_ join(I_ i, I_ end, const T_ &joiner)
Definition join.hh:45
std::string stringify(const T_ &item)
Definition stringify.hh:166
Definition about_metadata-fwd.hh:24