#include "commands.h" #include #include enum { OPT_NAME, OPT_NAME_VALUE, OPT_DESCRIPTION, OPT_DESCRIPTION_VALUE, ARG_REPO_PATH, }; static int create( const fx_command *self, const fx_arglist *opt, const fx_array *args) { const char *root_path = NULL; fx_arglist_get_string( opt, FX_COMMAND_INVALID_ID, ARG_REPO_PATH, 0, &root_path); if (!root_path) { fx_arglist_report_missing_args( opt, FX_COMMAND_INVALID_ID, ARG_REPO_PATH, 0); return -1; } struct ropkg_repo_mgmt *repo = NULL; fx_result result = ropkg_repo_mgmt_create(root_path, &repo); if (fx_result_is_error(result)) { fx_throw(result); return -1; } ropkg_repo_mgmt_close(repo); return 0; } FX_COMMAND(CMD_CREATE, CMD_ROOT) { FX_COMMAND_NAME("create"); FX_COMMAND_SHORT_NAME('N'); FX_COMMAND_DESC("create a new repository."); FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT); FX_COMMAND_FUNCTION(create); FX_COMMAND_HELP_OPTION(); FX_COMMAND_OPTION(OPT_NAME) { FX_OPTION_LONG_NAME("name"); FX_OPTION_SHORT_NAME('n'); FX_OPTION_DESC("the human-readable name of the repository"); FX_OPTION_ARG(OPT_NAME_VALUE) { FX_ARG_NAME("name"); FX_ARG_NR_VALUES(1); } } FX_COMMAND_OPTION(OPT_DESCRIPTION) { FX_OPTION_LONG_NAME("description"); FX_OPTION_SHORT_NAME('d'); FX_OPTION_DESC( "a human-readable description of the repository"); FX_OPTION_ARG(OPT_DESCRIPTION_VALUE) { FX_ARG_NAME("description"); FX_ARG_NR_VALUES(1); } } FX_COMMAND_ARG(ARG_REPO_PATH) { FX_ARG_NAME("path"); FX_ARG_DESC("the path to create the repository at."); FX_ARG_NR_VALUES(1); } }