implemented initial dpm core call functionality from module perspective

This commit is contained in:
Chris Punches
2025-03-01 20:57:38 -05:00
parent a5e2c86882
commit 6220653d10
4 changed files with 99 additions and 31 deletions

View File

@@ -1,38 +1,12 @@
/**
* @file info.cpp
* @brief Implementation of the DPM info module
*
* Provides information about the DPM system through a module interface.
* This module supports commands for displaying version information,
* system details, and module help documentation.
*
* @copyright Copyright (c) 2025 SILO GROUP LLC
* @author Chris Punches <chris.punches@silogroup.org>
*
* Part of the Dark Horse Linux Package Manager (DPM)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* For bug reports or contributions, please contact the dhlp-contributors
* mailing list at: https://lists.darkhorselinux.org/mailman/listinfo/dhlp-contributors
*/
// info.cpp
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
// Declaration of the DPM core function we want to call
extern "C" int dpm_core_callback(const char* action, const char* data);
// Implementation of the info module
// This module provides information about the DPM system
@@ -56,6 +30,8 @@ extern "C" int dpm_module_execute(const char* command, int argc, char** argv) {
std::cout << " version - Display DPM version information\n";
std::cout << " system - Display system information\n";
std::cout << " help - Display this help message\n";
dpm_core_callback("log", "No command specified, displayed help");
return 0;
}
@@ -63,12 +39,19 @@ extern "C" int dpm_module_execute(const char* command, int argc, char** argv) {
std::string cmd(command);
if (cmd == "version") {
dpm_core_callback("log", "Executing 'version' command");
std::cout << "DPM Version: 0.1.0\n";
std::cout << "Build Date: " << __DATE__ << "\n";
std::cout << "Build Time: " << __TIME__ << "\n";
return 0;
}
else if (cmd == "system") {
dpm_core_callback("log", "Executing 'system' command");
// Request config information
dpm_core_callback("get_config", "system.arch");
std::cout << "System Information:\n";
std::cout << " OS: "
#ifdef _WIN32
@@ -97,6 +80,8 @@ extern "C" int dpm_module_execute(const char* command, int argc, char** argv) {
return 0;
}
else if (cmd == "help") {
dpm_core_callback("log", "Executing 'help' command");
std::cout << "DPM Info Module - Provides information about the DPM system\n";
std::cout << "Available commands:\n";
std::cout << " version - Display DPM version information\n";
@@ -105,6 +90,9 @@ extern "C" int dpm_module_execute(const char* command, int argc, char** argv) {
return 0;
}
else {
std::string error_msg = "Unknown command: " + cmd;
dpm_core_callback("log", error_msg.c_str());
std::cerr << "Unknown command: " << cmd << "\n";
std::cerr << "Run 'dpm info help' for a list of available commands\n";
return 1;