continued restructure for dpmdk and updated default behaviour

This commit is contained in:
Chris Punches
2025-03-08 17:44:23 -05:00
parent f0859c93c3
commit 255debef50
10 changed files with 73 additions and 28 deletions

View File

@@ -48,9 +48,10 @@
// the default behaviour if dpm is executed without being told to do anything
int default_behavior(const ModuleLoader& loader)
{
return main_list_modules(loader);
return main_show_help();
}
/**
* @brief Entry point for the DPM utility
*
@@ -131,24 +132,33 @@ int main( int argc, char* argv[] )
return path_check_result;
}
// If help is requested, show it and exit
if (args.show_help) {
return main_show_help();
}
// If list modules is requested, show the list and exit
if (args.list_modules) {
return main_list_modules(loader);
}
// if no module is provided to execute, then trigger the default
// dpm behaviour
if ( args.module_name.empty() )
{
return default_behavior( loader );
// behaviour (show help)
if (args.module_name.empty()) {
return default_behavior(loader);
}
// execute the module
DPMErrorCategory execute_error = loader.execute_module( args.module_name, args.command );
DPMErrorCategory execute_error = loader.execute_module(args.module_name, args.command);
std::string absolute_modules_path;
loader.get_module_path( absolute_modules_path );
loader.get_module_path(absolute_modules_path);
// construct an error object
FlexDPMError result = make_error( execute_error );
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);
}
}