cleaned up entry point for dpm core
parent
255debef50
commit
525462a144
|
@ -86,4 +86,20 @@ int main_list_modules(const ModuleLoader& loader);
|
||||||
*/
|
*/
|
||||||
int main_show_help();
|
int main_show_help();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Executes a DPM module with the specified command
|
||||||
|
*
|
||||||
|
* Attempts to execute the specified module with the given command string and
|
||||||
|
* handles any errors that occur during execution. If the execution is successful,
|
||||||
|
* returns 0. If an error occurs, constructs an appropriate error context and
|
||||||
|
* processes it through the error handling system.
|
||||||
|
*
|
||||||
|
* @param loader Reference to a ModuleLoader object that provides access to modules
|
||||||
|
* @param module_name Name of the module to execute
|
||||||
|
* @param command Command string to pass to the module
|
||||||
|
* @return 0 on successful execution, appropriate error code otherwise
|
||||||
|
*/
|
||||||
|
int main_execute_module( const ModuleLoader& loader, std::string module_name, std::string command );
|
||||||
|
|
||||||
|
|
||||||
/** @} */ // end of dpm_interface group
|
/** @} */ // end of dpm_interface group
|
13
src/dpm.cpp
13
src/dpm.cpp
|
@ -149,16 +149,5 @@ int main( int argc, char* argv[] )
|
||||||
}
|
}
|
||||||
|
|
||||||
// execute the module
|
// execute the module
|
||||||
DPMErrorCategory execute_error = loader.execute_module(args.module_name, args.command);
|
int return_code = main_execute_module( loader, args.module_name, args.command );
|
||||||
|
|
||||||
std::string absolute_modules_path;
|
|
||||||
loader.get_module_path(absolute_modules_path);
|
|
||||||
|
|
||||||
// construct an error object
|
|
||||||
FlexDPMError result = make_error(execute_error);
|
|
||||||
result.module_name = args.module_name.c_str();
|
|
||||||
result.module_path = absolute_modules_path.c_str();
|
|
||||||
|
|
||||||
// pair result with a message and exit with the appropriate error code
|
|
||||||
return handle_error(result);
|
|
||||||
}
|
}
|
|
@ -30,6 +30,8 @@
|
||||||
|
|
||||||
#include "dpm_interface.hpp"
|
#include "dpm_interface.hpp"
|
||||||
|
|
||||||
|
#include <handlers.hpp>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DPM Interface methods.
|
* DPM Interface methods.
|
||||||
*
|
*
|
||||||
|
@ -186,3 +188,22 @@ int main_show_help() {
|
||||||
<< "For module-specific help, use: dpm <module-name> help\n\n";
|
<< "For module-specific help, use: dpm <module-name> help\n\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main_execute_module( const ModuleLoader& loader, std::string module_name, std::string command ) {
|
||||||
|
DPMErrorCategory execute_error = loader.execute_module(module_name, command);
|
||||||
|
if (execute_error != DPMErrorCategory::SUCCESS) {
|
||||||
|
// get the absolute module path
|
||||||
|
std::string absolute_module_path = "";
|
||||||
|
loader.get_module_path(absolute_module_path);
|
||||||
|
|
||||||
|
// construct an error object
|
||||||
|
FlexDPMError result = make_error( execute_error );
|
||||||
|
result.module_name = module_name.c_str();
|
||||||
|
result.module_path = absolute_module_path.c_str();
|
||||||
|
|
||||||
|
// pair result with a message and return with the appropriate error code
|
||||||
|
return handle_error(result);
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue