restructured the build module

This commit is contained in:
Chris Punches
2025-03-11 00:55:16 -04:00
parent f750c22faa
commit 368b751a63
10 changed files with 428 additions and 303 deletions

View File

@@ -1,25 +1,14 @@
/**
* @file buildFuncs.hpp
* @brief Header file for the build module support functions
*
* Defines functions and enumerations for the build module which creates
* DPM packages according to specification.
*
* @copyright Copyright (c) 2025 SILO GROUP LLC
* @author Chris Punches <chris.punches@silogroup.org>
*
* Part of the Dark Horse Linux Package Manager (DPM)
*/
#pragma once
#include <dpmdk/include/CommonModuleAPI.hpp>
#include <string>
#include <cstring>
#include <vector>
#include <getopt.h>
#include <dpmdk/include/CommonModuleAPI.hpp>
#include <filesystem>
#include "helpers.hpp"
/**
* @enum Command
* @enum Command
* @brief Enumeration of supported commands for the build module
*/
enum Command {
@@ -41,6 +30,7 @@ struct BuildOptions {
std::string signature_key; /**< Path to the GPG key for signing the package */
bool force; /**< Flag to force package creation even if warnings occur */
bool verbose; /**< Flag for verbose output */
bool show_help; /**< Flag to show help information */
// Constructor with default values
BuildOptions() :
@@ -51,54 +41,10 @@ struct BuildOptions {
package_name(""),
signature_key(""),
force(false),
verbose(false) {}
verbose(false),
show_help(false) {}
};
/**
* @brief Handler for the help command
*
* Displays information about available commands in the build module.
*
* @param argc Number of arguments
* @param argv Array of arguments
* @return 0 on success, non-zero on failure
*/
int cmd_help(int argc, char** argv);
/**
* @brief Handler for the create command
*
* Processes arguments and creates a DPM package.
*
* @param argc Number of arguments
* @param argv Array of arguments
* @return 0 on success, non-zero on failure
*/
int cmd_create(int argc, char** argv);
/**
* @brief Handler for unknown commands
*
* Displays an error message for unrecognized commands.
*
* @param command The unrecognized command string
* @param argc Number of arguments
* @param argv Array of arguments
* @return 1 to indicate failure
*/
int cmd_unknown(const char* command, int argc, char** argv);
/**
* @brief Parses a command string into a Command enum value
*
* Converts a command string to the appropriate Command enum value
* for internal routing.
*
* @param cmd_str The command string to parse
* @return The corresponding Command enum value
*/
Command parse_command(const char* cmd_str);
/**
* @brief Parses command-line arguments for the create command
*
@@ -111,6 +57,17 @@ Command parse_command(const char* cmd_str);
*/
int parse_create_options(int argc, char** argv, BuildOptions& options);
/**
* @brief Parses a command string into a Command enum value
*
* Converts a command string to the appropriate Command enum value
* for internal routing.
*
* @param cmd_str The command string to parse
* @return The corresponding Command enum value
*/
Command parse_command(const char* cmd_str);
/**
* @brief Validates the build options
*

View File

@@ -0,0 +1,27 @@
#pragma once
#include "cli_parsers.hpp"
#include <dpmdk/include/CommonModuleAPI.hpp>
#include <filesystem>
/**
* @brief Handler for the create command
*
* Processes arguments and creates a DPM package.
*
* @param argc Number of arguments
* @param argv Array of arguments
* @return 0 on success, non-zero on failure
*/
int cmd_create(int argc, char** argv);
/**
* @brief Handler for the help command
*
* Displays information about available commands in the build module.
*
* @param argc Number of arguments
* @param argv Array of arguments
* @return 0 on success, non-zero on failure
*/
int cmd_help(int argc, char** argv);

View File

@@ -0,0 +1,56 @@
/**
* @file helpers.hpp
* @brief Header file for the build module support functions
*
* Defines functions and enumerations for the build module which creates
* DPM packages according to specification.
*
* @copyright Copyright (c) 2025 SILO GROUP LLC
* @author Chris Punches <chris.punches@silogroup.org>
*
* Part of the Dark Horse Linux Package Manager (DPM)
*/
#pragma once
#include <string>
#include <cstring>
#include <vector>
#include <getopt.h>
#include <cstdlib>
#include <wordexp.h>
#include <dpmdk/include/CommonModuleAPI.hpp>
/**
* @brief Expands environment variables and tildes in a path
*
* Uses wordexp to handle shell-like expansions in paths,
* including environment variables, tildes, and wildcards.
*
* @param path The path string to expand
* @return The expanded path, or the original path if expansion failed
*/
std::string expand_path(const std::string& path);
/**
* @brief Handler for the help command
*
* Displays information about available commands in the build module.
*
* @param argc Number of arguments
* @param argv Array of arguments
* @return 0 on success, non-zero on failure
*/
int cmd_help(int argc, char** argv);
/**
* @brief Handler for unknown commands
*
* Displays an error message for unrecognized commands.
*
* @param command The unrecognized command string
* @param argc Number of arguments
* @param argv Array of arguments
* @return 1 to indicate failure
*/
int cmd_unknown(const char* command, int argc, char** argv);