2025-03-11 04:55:16 +00:00
|
|
|
#include "commands.hpp"
|
|
|
|
|
2025-03-13 23:15:42 +00:00
|
|
|
|
2025-03-13 00:05:59 +00:00
|
|
|
int cmd_stage(int argc, char** argv) {
|
2025-03-11 04:55:16 +00:00
|
|
|
// create a container for commandline options
|
|
|
|
BuildOptions options;
|
|
|
|
|
|
|
|
// Parse command-line options
|
|
|
|
int parse_result = parse_create_options(argc, argv, options);
|
|
|
|
if (parse_result != 0) {
|
|
|
|
return parse_result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If help was requested, show it and return
|
|
|
|
if (options.show_help) {
|
|
|
|
return cmd_help(argc, argv);
|
|
|
|
}
|
|
|
|
|
2025-03-13 23:15:42 +00:00
|
|
|
// Set logging level to DEBUG when verbose is enabled
|
|
|
|
if (options.verbose) {
|
|
|
|
dpm_set_logging_level(LOG_DEBUG);
|
|
|
|
}
|
|
|
|
|
2025-03-11 04:55:16 +00:00
|
|
|
// Validate options
|
|
|
|
int validate_result = validate_build_options(options);
|
|
|
|
if (validate_result != 0) {
|
|
|
|
return validate_result;
|
|
|
|
}
|
|
|
|
|
2025-03-13 23:15:42 +00:00
|
|
|
// Log detailed options (only visible in verbose mode)
|
|
|
|
dpm_log(LOG_DEBUG, "Staging DPM package with the following options:");
|
|
|
|
dpm_log(LOG_DEBUG, (" Output directory: " + options.output_dir).c_str());
|
|
|
|
dpm_log(LOG_DEBUG, (" Contents directory: " + options.contents_dir).c_str());
|
2025-03-11 04:55:16 +00:00
|
|
|
|
2025-03-13 23:15:42 +00:00
|
|
|
if (!options.hooks_dir.empty()) {
|
|
|
|
dpm_log(LOG_DEBUG, (" Hooks directory: " + options.hooks_dir).c_str());
|
|
|
|
}
|
2025-03-11 04:55:16 +00:00
|
|
|
|
2025-03-13 23:15:42 +00:00
|
|
|
if (!options.package_name.empty()) {
|
|
|
|
dpm_log(LOG_DEBUG, (" Package name: " + options.package_name).c_str());
|
|
|
|
}
|
2025-03-11 04:55:16 +00:00
|
|
|
|
2025-03-13 23:15:42 +00:00
|
|
|
if (options.force) {
|
|
|
|
dpm_log(LOG_DEBUG, " Force: Yes");
|
2025-03-11 04:55:16 +00:00
|
|
|
}
|
|
|
|
|
2025-03-13 23:15:42 +00:00
|
|
|
// Standard info logs that are always visible
|
2025-03-13 00:05:59 +00:00
|
|
|
dpm_log(LOG_INFO, "Package staging functionality not yet implemented");
|
|
|
|
dpm_log(LOG_INFO, "Would stage package directory using the provided options");
|
2025-03-11 04:55:16 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cmd_help(int argc, char** argv) {
|
|
|
|
dpm_log(LOG_INFO, "DPM Build Module - Creates DPM packages according to specification");
|
|
|
|
dpm_log(LOG_INFO, "Available commands:");
|
2025-03-13 00:05:59 +00:00
|
|
|
dpm_log(LOG_INFO, " stage - Stage a new DPM package directory");
|
2025-03-11 04:55:16 +00:00
|
|
|
dpm_log(LOG_INFO, " help - Display this help message");
|
|
|
|
dpm_log(LOG_INFO, "");
|
2025-03-13 00:05:59 +00:00
|
|
|
dpm_log(LOG_INFO, "Usage: dpm build stage [options]");
|
2025-03-11 04:55:16 +00:00
|
|
|
dpm_log(LOG_INFO, "Options:");
|
2025-03-13 00:05:59 +00:00
|
|
|
dpm_log(LOG_INFO, " -o, --output-dir DIR Directory to save the staged package (default: current directory)");
|
2025-03-11 04:55:16 +00:00
|
|
|
dpm_log(LOG_INFO, " -c, --contents DIR Directory with package contents (required)");
|
|
|
|
dpm_log(LOG_INFO, " -H, --hooks DIR Directory with package hooks (optional)");
|
|
|
|
dpm_log(LOG_INFO, " -n, --name NAME Package name (required if not in metadata)");
|
2025-03-13 00:05:59 +00:00
|
|
|
dpm_log(LOG_INFO, " -f, --force Force package staging even if warnings occur");
|
2025-03-11 04:55:16 +00:00
|
|
|
dpm_log(LOG_INFO, " -v, --verbose Enable verbose output");
|
|
|
|
dpm_log(LOG_INFO, " -h, --help Display this help message");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cmd_unknown(const char* command, int argc, char** argv) {
|
|
|
|
std::string msg = "Unknown command: ";
|
|
|
|
msg += (command ? command : "");
|
|
|
|
dpm_log(LOG_WARN, msg.c_str());
|
|
|
|
dpm_log(LOG_WARN, "Run 'dpm build help' for a list of available commands");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|