fleshing out package workflow
parent
1a97621a53
commit
80de44b1b6
|
@ -85,15 +85,15 @@ extern "C" int dpm_module_execute(const char* command, int argc, char** argv) {
|
||||||
|
|
||||||
// Route to the appropriate command handler
|
// Route to the appropriate command handler
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case CMD_CREATE:
|
case CMD_STAGE:
|
||||||
return cmd_create(argc, argv);
|
return cmd_stage(argc, argv);
|
||||||
|
|
||||||
case CMD_HELP:
|
case CMD_HELP:
|
||||||
return cmd_help(argc, argv);
|
return cmd_help(argc, argv);
|
||||||
|
|
||||||
case CMD_UNKNOWN:
|
case CMD_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
return cmd_unknown(command, argc, argv);
|
return cmd_unknown(command, argc, argv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
enum Command {
|
enum Command {
|
||||||
CMD_UNKNOWN, /**< Unknown or unsupported command */
|
CMD_UNKNOWN, /**< Unknown or unsupported command */
|
||||||
CMD_HELP, /**< Display help information */
|
CMD_HELP, /**< Display help information */
|
||||||
CMD_CREATE /**< Create a new DPM package */
|
CMD_STAGE /**< Stage a new DPM package */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +24,6 @@ enum Command {
|
||||||
struct BuildOptions {
|
struct BuildOptions {
|
||||||
std::string output_dir; /**< Directory where to save the built package */
|
std::string output_dir; /**< Directory where to save the built package */
|
||||||
std::string contents_dir; /**< Directory with package contents */
|
std::string contents_dir; /**< Directory with package contents */
|
||||||
std::string metadata_dir; /**< Directory with package metadata */
|
|
||||||
std::string hooks_dir; /**< Directory with package hooks */
|
std::string hooks_dir; /**< Directory with package hooks */
|
||||||
std::string package_name; /**< Name of the package to build */
|
std::string package_name; /**< Name of the package to build */
|
||||||
bool force; /**< Flag to force package creation even if warnings occur */
|
bool force; /**< Flag to force package creation even if warnings occur */
|
||||||
|
@ -35,7 +34,6 @@ struct BuildOptions {
|
||||||
BuildOptions() :
|
BuildOptions() :
|
||||||
output_dir("."),
|
output_dir("."),
|
||||||
contents_dir(""),
|
contents_dir(""),
|
||||||
metadata_dir(""),
|
|
||||||
hooks_dir(""),
|
hooks_dir(""),
|
||||||
package_name(""),
|
package_name(""),
|
||||||
force(false),
|
force(false),
|
||||||
|
|
|
@ -5,15 +5,15 @@
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handler for the create command
|
* @brief Handler for the stage command
|
||||||
*
|
*
|
||||||
* Processes arguments and creates a DPM package.
|
* Processes arguments and stages a DPM package.
|
||||||
*
|
*
|
||||||
* @param argc Number of arguments
|
* @param argc Number of arguments
|
||||||
* @param argv Array of arguments
|
* @param argv Array of arguments
|
||||||
* @return 0 on success, non-zero on failure
|
* @return 0 on success, non-zero on failure
|
||||||
*/
|
*/
|
||||||
int cmd_create(int argc, char** argv);
|
int cmd_stage(int argc, char** argv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handler for the help command
|
* @brief Handler for the help command
|
||||||
|
@ -36,4 +36,4 @@ int cmd_help(int argc, char** argv);
|
||||||
* @param argv Array of arguments
|
* @param argv Array of arguments
|
||||||
* @return 1 to indicate failure
|
* @return 1 to indicate failure
|
||||||
*/
|
*/
|
||||||
int cmd_unknown(const char* command, int argc, char** argv);
|
int cmd_unknown(const char* command, int argc, char** argv);
|
|
@ -24,8 +24,6 @@ int parse_create_options(int argc, char** argv, BuildOptions& options) {
|
||||||
options.output_dir = value;
|
options.output_dir = value;
|
||||||
} else if (option == "--contents") {
|
} else if (option == "--contents") {
|
||||||
options.contents_dir = value;
|
options.contents_dir = value;
|
||||||
} else if (option == "--metadata") {
|
|
||||||
options.metadata_dir = value;
|
|
||||||
} else if (option == "--hooks") {
|
} else if (option == "--hooks") {
|
||||||
options.hooks_dir = value;
|
options.hooks_dir = value;
|
||||||
} else if (option == "--name") {
|
} else if (option == "--name") {
|
||||||
|
@ -46,7 +44,6 @@ int parse_create_options(int argc, char** argv, BuildOptions& options) {
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"output-dir", required_argument, 0, 'o'},
|
{"output-dir", required_argument, 0, 'o'},
|
||||||
{"contents", required_argument, 0, 'c'},
|
{"contents", required_argument, 0, 'c'},
|
||||||
{"metadata", required_argument, 0, 'm'},
|
|
||||||
{"hooks", required_argument, 0, 'H'},
|
{"hooks", required_argument, 0, 'H'},
|
||||||
{"name", required_argument, 0, 'n'},
|
{"name", required_argument, 0, 'n'},
|
||||||
{"force", no_argument, 0, 'f'},
|
{"force", no_argument, 0, 'f'},
|
||||||
|
@ -63,7 +60,7 @@ int parse_create_options(int argc, char** argv, BuildOptions& options) {
|
||||||
int opt;
|
int opt;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "o:c:m:H:n:fvh", long_options, &option_index)) != -1) {
|
while ((opt = getopt_long(argc, argv, "o:c:H:n:fvh", long_options, &option_index)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'o':
|
case 'o':
|
||||||
options.output_dir = optarg;
|
options.output_dir = optarg;
|
||||||
|
@ -71,9 +68,6 @@ int parse_create_options(int argc, char** argv, BuildOptions& options) {
|
||||||
case 'c':
|
case 'c':
|
||||||
options.contents_dir = optarg;
|
options.contents_dir = optarg;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
|
||||||
options.metadata_dir = optarg;
|
|
||||||
break;
|
|
||||||
case 'H':
|
case 'H':
|
||||||
options.hooks_dir = optarg;
|
options.hooks_dir = optarg;
|
||||||
break;
|
break;
|
||||||
|
@ -106,10 +100,6 @@ int parse_create_options(int argc, char** argv, BuildOptions& options) {
|
||||||
options.contents_dir = expand_path(options.contents_dir);
|
options.contents_dir = expand_path(options.contents_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.metadata_dir.empty()) {
|
|
||||||
options.metadata_dir = expand_path(options.metadata_dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!options.hooks_dir.empty()) {
|
if (!options.hooks_dir.empty()) {
|
||||||
options.hooks_dir = expand_path(options.hooks_dir);
|
options.hooks_dir = expand_path(options.hooks_dir);
|
||||||
}
|
}
|
||||||
|
@ -132,8 +122,8 @@ Command parse_command(const char* cmd_str) {
|
||||||
else if (strcmp(cmd_str, "help") == 0) {
|
else if (strcmp(cmd_str, "help") == 0) {
|
||||||
return CMD_HELP;
|
return CMD_HELP;
|
||||||
}
|
}
|
||||||
else if (strcmp(cmd_str, "create") == 0) {
|
else if (strcmp(cmd_str, "stage") == 0) {
|
||||||
return CMD_CREATE;
|
return CMD_STAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CMD_UNKNOWN;
|
return CMD_UNKNOWN;
|
||||||
|
@ -151,17 +141,6 @@ int validate_build_options(const BuildOptions& options) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if metadata directory is provided and exists
|
|
||||||
if (options.metadata_dir.empty()) {
|
|
||||||
dpm_log(LOG_ERROR, "Metadata directory is required (--metadata)");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!std::filesystem::exists(options.metadata_dir)) {
|
|
||||||
dpm_log(LOG_ERROR, ("Metadata directory does not exist: " + options.metadata_dir).c_str());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if hooks directory exists if provided
|
// Check if hooks directory exists if provided
|
||||||
if (!options.hooks_dir.empty() && !std::filesystem::exists(options.hooks_dir)) {
|
if (!options.hooks_dir.empty() && !std::filesystem::exists(options.hooks_dir)) {
|
||||||
dpm_log(LOG_ERROR, ("Hooks directory does not exist: " + options.hooks_dir).c_str());
|
dpm_log(LOG_ERROR, ("Hooks directory does not exist: " + options.hooks_dir).c_str());
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "commands.hpp"
|
#include "commands.hpp"
|
||||||
|
|
||||||
int cmd_create(int argc, char** argv) {
|
int cmd_stage(int argc, char** argv) {
|
||||||
// create a container for commandline options
|
// create a container for commandline options
|
||||||
BuildOptions options;
|
BuildOptions options;
|
||||||
|
|
||||||
|
@ -23,10 +23,9 @@ int cmd_create(int argc, char** argv) {
|
||||||
|
|
||||||
// Log the operation
|
// Log the operation
|
||||||
if (options.verbose) {
|
if (options.verbose) {
|
||||||
dpm_log(LOG_INFO, "Creating DPM package with the following options:");
|
dpm_log(LOG_INFO, "Staging DPM package with the following options:");
|
||||||
dpm_log(LOG_INFO, (" Output directory: " + options.output_dir).c_str());
|
dpm_log(LOG_INFO, (" Output directory: " + options.output_dir).c_str());
|
||||||
dpm_log(LOG_INFO, (" Contents directory: " + options.contents_dir).c_str());
|
dpm_log(LOG_INFO, (" Contents directory: " + options.contents_dir).c_str());
|
||||||
dpm_log(LOG_INFO, (" Metadata directory: " + options.metadata_dir).c_str());
|
|
||||||
|
|
||||||
if (!options.hooks_dir.empty()) {
|
if (!options.hooks_dir.empty()) {
|
||||||
dpm_log(LOG_INFO, (" Hooks directory: " + options.hooks_dir).c_str());
|
dpm_log(LOG_INFO, (" Hooks directory: " + options.hooks_dir).c_str());
|
||||||
|
@ -41,27 +40,27 @@ int cmd_create(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For now, just log that we would create the package
|
// For now, just log that we would stage the package
|
||||||
dpm_log(LOG_INFO, "Package creation functionality not yet implemented");
|
dpm_log(LOG_INFO, "Package staging functionality not yet implemented");
|
||||||
dpm_log(LOG_INFO, "Would create package using the provided options");
|
dpm_log(LOG_INFO, "Would stage package directory using the provided options");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int cmd_help(int argc, char** argv) {
|
int cmd_help(int argc, char** argv) {
|
||||||
dpm_log(LOG_INFO, "DPM Build Module - Creates DPM packages according to specification");
|
dpm_log(LOG_INFO, "DPM Build Module - Creates DPM packages according to specification");
|
||||||
dpm_log(LOG_INFO, "Available commands:");
|
dpm_log(LOG_INFO, "Available commands:");
|
||||||
dpm_log(LOG_INFO, " create - Create a new DPM package");
|
dpm_log(LOG_INFO, " stage - Stage a new DPM package directory");
|
||||||
dpm_log(LOG_INFO, " help - Display this help message");
|
dpm_log(LOG_INFO, " help - Display this help message");
|
||||||
dpm_log(LOG_INFO, "");
|
dpm_log(LOG_INFO, "");
|
||||||
dpm_log(LOG_INFO, "Usage: dpm build create [options]");
|
dpm_log(LOG_INFO, "Usage: dpm build stage [options]");
|
||||||
dpm_log(LOG_INFO, "Options:");
|
dpm_log(LOG_INFO, "Options:");
|
||||||
dpm_log(LOG_INFO, " -o, --output-dir DIR Directory to save the built package (default: current directory)");
|
dpm_log(LOG_INFO, " -o, --output-dir DIR Directory to save the staged package (default: current directory)");
|
||||||
dpm_log(LOG_INFO, " -c, --contents DIR Directory with package contents (required)");
|
dpm_log(LOG_INFO, " -c, --contents DIR Directory with package contents (required)");
|
||||||
dpm_log(LOG_INFO, " -m, --metadata DIR Directory with package metadata (required)");
|
|
||||||
dpm_log(LOG_INFO, " -H, --hooks DIR Directory with package hooks (optional)");
|
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)");
|
dpm_log(LOG_INFO, " -n, --name NAME Package name (required if not in metadata)");
|
||||||
dpm_log(LOG_INFO, " -f, --force Force package creation even if warnings occur");
|
dpm_log(LOG_INFO, " -f, --force Force package staging even if warnings occur");
|
||||||
dpm_log(LOG_INFO, " -v, --verbose Enable verbose output");
|
dpm_log(LOG_INFO, " -v, --verbose Enable verbose output");
|
||||||
dpm_log(LOG_INFO, " -h, --help Display this help message");
|
dpm_log(LOG_INFO, " -h, --help Display this help message");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue