mirror of
https://github.com/davidallendj/gdpm.git
synced 2025-12-20 11:37:00 -07:00
Added CI script, updated dependencies, and fixed bugs
-Added CI yaml file for workflows -Added `doctest` as dependency -Added test target executable to CMakeLists.txt -Renamed `bin` scripts to remove `gdpm*` prefix -Updated `SQLite 3` dependency in CMakeLists.txt -Implement basic unit testing in `tests/basic.cpp` -Fixed issue with handling `fmt` strings
This commit is contained in:
parent
e36f0aee79
commit
e048a762b2
22 changed files with 169 additions and 38 deletions
|
|
@ -26,8 +26,8 @@
|
|||
|
||||
|
||||
namespace gdpm::config{
|
||||
config_context config;
|
||||
std::string to_json(const config_context& params){
|
||||
context config;
|
||||
std::string to_json(const context& params){
|
||||
auto _build_json_array = [](std::set<std::string> a){
|
||||
std::string o{"["};
|
||||
for(const std::string& src : a)
|
||||
|
|
@ -57,7 +57,8 @@ namespace gdpm::config{
|
|||
return json;
|
||||
}
|
||||
|
||||
config_context load(std::filesystem::path path, int verbose){
|
||||
|
||||
context load(std::filesystem::path path, int verbose){
|
||||
std::fstream file;
|
||||
file.open(path, std::ios::in);
|
||||
if(!file){
|
||||
|
|
@ -75,7 +76,7 @@ namespace gdpm::config{
|
|||
*/
|
||||
using namespace rapidjson;
|
||||
|
||||
/* Read JSON fro config, parse, and check document. Must make sure that program does not crash here and use default config instead! */
|
||||
/* Read JSON from config, parse, and check document. Must make sure that program does not crash here and use default config instead! */
|
||||
std::string contents, line;
|
||||
while(std::getline(file, line))
|
||||
contents += line + "\n";
|
||||
|
|
@ -99,7 +100,7 @@ namespace gdpm::config{
|
|||
// if(!status){
|
||||
// log::error("config::load: Could not parse contents of file (Error: {}/{}).", GetParseError_En(status), doc.GetErrorOffset());
|
||||
|
||||
// return config_context();
|
||||
// return context();
|
||||
// }
|
||||
|
||||
/* Must check if keys exists first, then populate _config_params. */
|
||||
|
|
@ -141,7 +142,8 @@ namespace gdpm::config{
|
|||
return config;
|
||||
}
|
||||
|
||||
int save(const config_context& config, int verbose){
|
||||
|
||||
int save(std::filesystem::path path, const context& config, int verbose){
|
||||
using namespace rapidjson;
|
||||
|
||||
/* Build a JSON string to pass to document */
|
||||
|
|
@ -152,7 +154,7 @@ namespace gdpm::config{
|
|||
/* Dump JSON config to file */
|
||||
Document doc;
|
||||
doc.Parse(json.c_str());
|
||||
std::ofstream ofs(config.path);
|
||||
std::ofstream ofs(path);
|
||||
OStreamWrapper osw(ofs);
|
||||
|
||||
PrettyWriter<OStreamWrapper> writer(osw);
|
||||
|
|
@ -161,8 +163,9 @@ namespace gdpm::config{
|
|||
return 0;
|
||||
}
|
||||
|
||||
config_context make_context(const std::string& username, const std::string& password, const std::string& path, const std::string& token, const std::string& godot_version, const std::string& packages_dir, const std::string& tmp_dir, const std::set<std::string>& remote_sources, size_t threads, size_t timeout, bool enable_sync, bool enable_file_logging, int verbose){
|
||||
config_context config {
|
||||
|
||||
context make_context(const std::string& username, const std::string& password, const std::string& path, const std::string& token, const std::string& godot_version, const std::string& packages_dir, const std::string& tmp_dir, const std::set<std::string>& remote_sources, size_t threads, size_t timeout, bool enable_sync, bool enable_file_logging, int verbose){
|
||||
context config {
|
||||
.username = username,
|
||||
.password = password,
|
||||
.path = path,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace gdpm::http{
|
|||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&buf);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, utils::curl_write_to_buffer);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, constants::UserAgent);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, constants::UserAgent.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, timeout);
|
||||
res = curl_easy_perform(curl);
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &r.code);
|
||||
|
|
@ -61,7 +61,7 @@ namespace gdpm::http{
|
|||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_fields);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&buf);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, utils::curl_write_to_buffer);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, constants::UserAgent);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, constants::UserAgent.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, timeout);
|
||||
res = curl_easy_perform(curl);
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &r.code);
|
||||
|
|
@ -109,7 +109,7 @@ namespace gdpm::http{
|
|||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, utils::curl_write_to_stream);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, constants::UserAgent);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, constants::UserAgent.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, timeout);
|
||||
res = curl_easy_perform(curl);
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &r.code);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
// Godot Package Manager (GPM)
|
||||
|
||||
#include "constants.hpp"
|
||||
#include "log.hpp"
|
||||
#include "config.hpp"
|
||||
#include "package_manager.hpp"
|
||||
|
||||
|
||||
int main(int argc, char **argv){
|
||||
gdpm::package_manager::initialize(argc, argv);
|
||||
gdpm::package_manager::execute();
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace gdpm::package_manager{
|
|||
std::vector<std::string> repo_sources;
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
config::config_context config;
|
||||
config::context config;
|
||||
rest_api::rest_api_context params;
|
||||
command_e command;
|
||||
std::vector<std::string> packages;
|
||||
|
|
@ -67,6 +67,7 @@ namespace gdpm::package_manager{
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int execute(){
|
||||
run_command(command, packages, opts);
|
||||
if(clean_tmp_dir)
|
||||
|
|
@ -118,8 +119,10 @@ namespace gdpm::package_manager{
|
|||
}
|
||||
|
||||
log::println("Packages to install: ");
|
||||
for(const auto& p : p_found)
|
||||
for(const auto& p : p_found){
|
||||
std::string output((p.is_installed) ? p.title + " (reinstall)" : p.title);
|
||||
log::print(" {} ", (p.is_installed) ? p.title + " (reinstall)" : p.title);
|
||||
}
|
||||
log::println("");
|
||||
|
||||
if(!skip_prompt){
|
||||
|
|
@ -566,7 +569,7 @@ namespace gdpm::package_manager{
|
|||
/* Parse command-line arguments using cxxopts */
|
||||
cxxopts::Options options(
|
||||
argv[0],
|
||||
"Experimental package manager made for managing assets for the Godot game engine.\n"
|
||||
"Experimental package manager made for managing assets for the Godot game engine through the command-line.\n"
|
||||
);
|
||||
options.allow_unrecognised_options();
|
||||
options.custom_help("[COMMAND] [OPTIONS...]");
|
||||
|
|
@ -879,4 +882,6 @@ namespace gdpm::package_manager{
|
|||
return cache::get_package_info_by_title(package_titles);
|
||||
}
|
||||
|
||||
} // namespace gdpm::package_manager
|
||||
} // namespace gdpm::package_manager
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue