directory restructure and documentation cleanup
This commit is contained in:
@@ -41,24 +41,6 @@
|
||||
* Also includes helpers related to the CLI.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Verify that the module path exists and is accessible.
|
||||
*
|
||||
* This function checks if the configured module path exists, is a directory,
|
||||
* and has the necessary read permissions.
|
||||
*
|
||||
* @param loader Reference to a ModuleLoader object that provides the module path
|
||||
*
|
||||
* @return 0 if the path exists and is accessible, 1 otherwise
|
||||
*
|
||||
* The function performs the following checks:
|
||||
* 1. Retrieves the module path from the loader
|
||||
* 2. Verifies that the path exists in the filesystem
|
||||
* 3. Confirms that the path is a directory
|
||||
* 4. Checks that the directory has read permissions
|
||||
*
|
||||
* If any check fails, an appropriate error message is displayed to stderr.
|
||||
*/
|
||||
int main_check_module_path(const ModuleLoader& loader)
|
||||
{
|
||||
std::string path;
|
||||
@@ -88,29 +70,7 @@ int main_check_module_path(const ModuleLoader& loader)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* List all available and valid DPM modules.
|
||||
*
|
||||
* This function retrieves and displays a formatted table of available DPM modules
|
||||
* from the specified module path, including their versions and descriptions.
|
||||
*
|
||||
* @param loader Reference to a ModuleLoader object that provides access to modules
|
||||
*
|
||||
* @return 0 on success, 1 on failure
|
||||
*
|
||||
* The function performs the following operations:
|
||||
* 1. Gets the configured module path from the loader
|
||||
* 2. Retrieves a list of all potential modules in that path
|
||||
* 3. Validates each module by checking for required symbols
|
||||
* 4. Collects version and description information from valid modules
|
||||
* 5. Formats and displays the information in a tabular format
|
||||
*
|
||||
* If no modules are found or if no valid modules are found, appropriate
|
||||
* messages are displayed.
|
||||
*
|
||||
* Modules are considered valid if they expose all required interface
|
||||
* symbols as defined in module_interface.hpp.
|
||||
*/
|
||||
|
||||
int main_list_modules(const ModuleLoader& loader)
|
||||
{
|
||||
// initialize an empty modules list
|
||||
|
||||
@@ -30,32 +30,6 @@
|
||||
|
||||
#include "dpm_interface_helpers.hpp"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse command line arguments for DPM.
|
||||
*
|
||||
* This function parses the command line arguments provided to DPM
|
||||
* and builds a CommandArgs structure containing the parsed values.
|
||||
*
|
||||
* @param argc The number of arguments provided to the program
|
||||
* @param argv Array of C-style strings containing the arguments
|
||||
*
|
||||
* @return CommandArgs structure containing the parsed command line arguments
|
||||
*
|
||||
* The function handles the following arguments:
|
||||
* - ``-m, --module-path PATH``: Sets the directory path where DPM modules are located
|
||||
* - ``-c, --config-dir PATH``: Sets the directory path where DPM configuration files are located
|
||||
* - ``-h, --help``: Displays a help message and exits
|
||||
*
|
||||
* Additional arguments are processed as follows:
|
||||
* - First non-option argument is treated as the module name
|
||||
* - All remaining arguments are combined into a single command string for the module
|
||||
*
|
||||
* If the argument contains spaces, it will be quoted in the command string.
|
||||
*
|
||||
* If no module name is provided, the module_name field will be empty.
|
||||
*/
|
||||
CommandArgs parse_args(int argc, char* argv[])
|
||||
{
|
||||
CommandArgs args;
|
||||
|
||||
@@ -29,28 +29,10 @@
|
||||
|
||||
#include "module_interface.hpp"
|
||||
|
||||
/**
|
||||
* @brief Function that provides direct access to configuration values
|
||||
*
|
||||
* This function allows modules to get configuration values directly.
|
||||
* It returns the string value from the configuration or nullptr if not found.
|
||||
*
|
||||
* @param section The configuration section name
|
||||
* @param key The configuration key within the section
|
||||
* @return The configuration value or nullptr if not found
|
||||
*/
|
||||
extern "C" const char* dpm_get_config(const char* section, const char* key) {
|
||||
return g_config_manager.getConfigValue(section, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Direct logging function for modules
|
||||
*
|
||||
* This function allows modules to log messages directly through the DPM logger.
|
||||
*
|
||||
* @param level The log level as an integer (0=FATAL, 1=ERROR, 2=WARN, 3=INFO, 4=DEBUG)
|
||||
* @param message The message to log
|
||||
*/
|
||||
extern "C" void dpm_log(int level, const char* message) {
|
||||
if (!message) {
|
||||
return;
|
||||
@@ -80,4 +62,4 @@ extern "C" void dpm_log(int level, const char* message) {
|
||||
}
|
||||
|
||||
g_logger.log(log_level, message);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user