1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
// Copyright Contributors to the DNF5 project.
// Copyright Contributors to the libdnf project.
// SPDX-License-Identifier: GPL-2.0-or-later
//
// This file is part of libdnf: https://github.com/rpm-software-management/libdnf/
//
// Libdnf is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// Libdnf is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libdnf. If not, see <https://www.gnu.org/licenses/>.
#include "repomanage.hpp"
#include <dnf5/iplugin.hpp>
using namespace dnf5;
namespace {
constexpr const char * PLUGIN_NAME{"repomanage"};
constexpr PluginVersion PLUGIN_VERSION{.major = 1, .minor = 0, .micro = 0};
constexpr PluginAPIVersion REQUIRED_PLUGIN_API_VERSION{.major = 2, .minor = 0};
constexpr const char * attrs[]{"author.name", "author.email", "description", nullptr};
constexpr const char * attrs_value[]{"Ales Matej", "amatej@redhat.com", "repomanage command."};
class RepomanageCmdPlugin : public IPlugin {
public:
using IPlugin::IPlugin;
PluginAPIVersion get_api_version() const noexcept override { return REQUIRED_PLUGIN_API_VERSION; }
const char * get_name() const noexcept override { return PLUGIN_NAME; }
PluginVersion get_version() const noexcept override { return PLUGIN_VERSION; }
const char * const * get_attributes() const noexcept override { return attrs; }
const char * get_attribute(const char * attribute) const noexcept override {
for (size_t i = 0; attrs[i]; ++i) {
if (std::strcmp(attribute, attrs[i]) == 0) {
return attrs_value[i];
}
}
return nullptr;
}
std::vector<std::unique_ptr<Command>> create_commands() override;
void finish() noexcept override {}
};
std::vector<std::unique_ptr<Command>> RepomanageCmdPlugin::create_commands() {
std::vector<std::unique_ptr<Command>> commands;
commands.push_back(std::make_unique<RepomanageCommand>(get_context()));
return commands;
}
std::exception_ptr last_exception;
} // namespace
PluginAPIVersion dnf5_plugin_get_api_version(void) {
return REQUIRED_PLUGIN_API_VERSION;
}
const char * dnf5_plugin_get_name(void) {
return PLUGIN_NAME;
}
PluginVersion dnf5_plugin_get_version(void) {
return PLUGIN_VERSION;
}
IPlugin * dnf5_plugin_new_instance([[maybe_unused]] ApplicationVersion application_version, Context & context) try {
return new RepomanageCmdPlugin(context);
} catch (...) {
last_exception = std::current_exception();
return nullptr;
}
void dnf5_plugin_delete_instance(IPlugin * plugin_object) {
delete plugin_object;
}
std::exception_ptr * dnf5_plugin_get_last_exception(void) {
return &last_exception;
}
|