Fixed search command not working properly

This commit is contained in:
David Allen 2023-07-02 17:28:18 -06:00
parent 8a7ada342a
commit fb7efdd7a4
10 changed files with 143 additions and 120 deletions

View file

@ -17,12 +17,7 @@ namespace gdpm::package{
}
namespace gdpm::config{
enum class print_style{
list = 0,
table = 1,
};
struct context{
string username;
string password;
@ -40,13 +35,13 @@ namespace gdpm::config{
bool clean_temporary;
int verbose = log::INFO;
print_style style = print_style::list;
print::style style = print::style::list;
package::info info;
rest_api::request_params rest_api_params;
};
string from_style(const print_style& style);
print_style to_style(const string& s);
string from_style(const print::style& style);
print::style to_style(const string& s);
string to_json(const context& config, bool pretty_print = false);
error load(std::filesystem::path path, context& config);
error save(std::filesystem::path path, const context& config);

View file

@ -18,6 +18,13 @@ namespace gdpm::constants{
constexpr std::string WHITESPACE = " \n\r\t\f\v";
}
namespace gdpm::print{
enum class style{
list = 0,
table = 1,
};
}
/* Define default macros to set when building with -DGPM_* */
#define GDPM_CONFIG_USERNAME ""
#define GDPM_CONFIG_PASSWORD ""

View file

@ -117,6 +117,7 @@ namespace gdpm::package {
GDPM_DLL_EXPORT void print_list(const rapidjson::Document& json);
GDPM_DLL_EXPORT void print_list(const info_list& packages);
GDPM_DLL_EXPORT void print_table(const info_list& packages);
GDPM_DLL_EXPORT void print_table(const rapidjson::Document& json);
GDPM_DLL_EXPORT result_t<info_list> get_package_info(const opts_t& opts);
GDPM_DLL_EXPORT result_t<title_list> get_package_titles(const info_list& packages);
GDPM_DLL_EXPORT void clean_temporary(const config::context& config, const title_list& package_titles);

View file

@ -39,28 +39,36 @@ namespace gdpm::rest_api{
enum type_e: int { any = 0, addon, project };
enum support_e: int { all = 0, official, community, testing };
enum sort_e: int { none = 0, rating, cost, name, updated };
/* TODO: Include all information with categories and not just type*/
struct category{
int id;
int type;
string name;
};
using categories = std::vector<category>;
struct request_params{
int type ;
int type;
int category;
int support;
string user;
string godot_version;
int max_results;
string user = "";
string cost = "";
string godot_version = "4.0";
int max_results = 500;
int page;
int offset;
int sort;
bool reverse;
int verbose;
};
request_params make_from_config(const config::context& config);
request_params make_request_params(type_e type = GDPM_DEFAULT_ASSET_TYPE, int category = GDPM_DEFAULT_ASSET_CATEGORY, support_e support = GDPM_DEFAULT_ASSET_SUPPORT, const string& user = GDPM_DEFAULT_ASSET_USER, const string& godot_version = GDPM_DEFAULT_ASSET_GODOT_VERSION, int max_results = GDPM_DEFAULT_ASSET_MAX_RESULTS, int page = GDPM_DEFAULT_ASSET_PAGE, sort_e sort = GDPM_DEFAULT_ASSET_SORT, bool reverse = GDPM_DEFAULT_ASSET_REVERSE, int verbose = GDPM_DEFAULT_ASSET_VERBOSE);
string to_json(const rapidjson::Document& doc);
string to_string(type_e type);
string to_string(support_e support);
string to_string(sort_e sort);
void _print_params(const request_params& params, const string& filter);
error print_params(const request_params& params, const string& filter = "");
error print_asset(const request_params& params, const string& filter = "", const print::style& style = print::style::list);
rapidjson::Document _parse_json(const string& r, int verbose = 0);
string _prepare_request(const string& url, const request_params& context, const string& filter);
@ -69,7 +77,6 @@ namespace gdpm::rest_api{
bool logout();
rapidjson::Document configure(const string& url = constants::HostUrl, type_e type = any, int verbose = 0);
rapidjson::Document get_assets_list(const string& url = constants::HostUrl, type_e type = GDPM_DEFAULT_ASSET_TYPE, int category = GDPM_DEFAULT_ASSET_CATEGORY, support_e support = GDPM_DEFAULT_ASSET_SUPPORT, const string& filter = GDPM_DEFAULT_ASSET_FILTER, const std::string& user = GDPM_DEFAULT_ASSET_USER, const std::string& godot_version = GDPM_DEFAULT_ASSET_GODOT_VERSION, int max_results = GDPM_DEFAULT_ASSET_MAX_RESULTS, int page = GDPM_DEFAULT_ASSET_PAGE, sort_e sort = GDPM_DEFAULT_ASSET_SORT, bool reverse = GDPM_DEFAULT_ASSET_REVERSE, int verbose = GDPM_DEFAULT_ASSET_VERBOSE);
rapidjson::Document get_assets_list(const string& url, const request_params& params = {}, const string& filter = "");
rapidjson::Document get_asset(const string& url, int asset_id, const request_params& params = {}, const string& filter = "");
bool delete_asset(int asset_id); // ...for moderators