gdpm/include/package.hpp
David J. Allen 5a73651ad1 Major refactor and API changes
- Updated `.gitignore` file
- Updated `CMakeLists.txt` to build static exectuable
- Changed some `Doxyfile` configurations to build more robust and complete documentation (WIP)
- Changed how `remote` works to better reflect `git`'s API (WIP)
- Changed how error handling works
- Improved `bin/compile.sh` script
- Improved `bin/lines.sh` script (kinda)
- Removed some instances of `fmt` in favor of `std` string functions
- Restructed style for better readibility
2023-05-22 17:54:45 -06:00

113 lines
No EOL
4.2 KiB
C++

#pragma once
#include "constants.hpp"
#include "error.hpp"
#include "package.hpp"
#include "types.hpp"
#include "result.hpp"
#include "config.hpp"
#include <cstdio>
#include <filesystem>
#include <string>
#include <vector>
#include <rapidjson/document.h>
namespace gdpm::package {
struct info {
size_t asset_id;
string type;
string title;
string author;
size_t author_id;
string version;
string godot_version;
string cost;
string description;
string modify_date;
string support_level;
string category;
string remote_source;
string download_url;
string download_hash;
bool is_installed;
string install_path;
std::vector<info> dependencies;
};
struct params {
enum install_method_e{
GLOBAL_LINK_LOCAL,
GLOBAL_CLONE_LOCAL,
GLOBAL_ONLY,
LOCAL_ONLY
};
bool parallel_jobs = 1;
bool use_cache = true;
bool use_remote = true;
bool skip_prompt = false;
std::string remote_source = "";
install_method_e install_method = GLOBAL_LINK_LOCAL;
};
using info_list = std::vector<info>;
using title_list = std::vector<string>;
using id_list = std::vector<size_t>;
using path = std::string;
using path_list = std::vector<path>;
/*!
@brief Install a Godot package from the Asset Library in the current project.
By default, packages are stored in a global directory and linked to the project
where the tool is executed. Use the `--jobs` option to install packages in
parallel. Specify which remote source to use by passing the `--remote` option.
By default, the first remote source will by used. Alternatively, if the
`--use-remote=false` option is passed, then the tool will only attempt to fetch the
package from cache. Use the `--use-cache=false` option to fetch package only from
remote source.
`gdpm install "super cool example package"
To only install a package global without linking to the project, use the
`--global-only` option.
`gdpm install --global-only "super cool example package"
To install a package to a local project only, use the `--local-only` option.
This will extract the package contents to the project location instead of the
global install location. Use the `--path` option to specify an alternative
path.
`gdpm install --local-only "super cool example package" --path addons/example
To copy the package to a project instead of linking, use the `--clone` option.
`gdpm install --clone "super cool examle package"
*/
GDPM_DLL_EXPORT error install(const config::context& config, const title_list& package_titles, const params& params = package::params());
/*!
@brief Remove's package and contents from local database.
*/
GDPM_DLL_EXPORT error remove(const config::context& config, const title_list& package_titles, const params& params = package::params());
GDPM_DLL_EXPORT error remove_all(const config::context& config, const params& params = package::params());
GDPM_DLL_EXPORT error update(const config::context& config, const title_list& package_titles, const params& params = package::params());
GDPM_DLL_EXPORT error search(const config::context& config, const title_list& package_titles, const params& params = package::params());
GDPM_DLL_EXPORT error list(const config::context& config, const args_t& args, const opts_t& opts);
GDPM_DLL_EXPORT error export_to(const path_list& paths);
GDPM_DLL_EXPORT error link(const config::context& config, const title_list& package_titles, const opts_t& opts);
GDPM_DLL_EXPORT error clone(const config::context& config, const title_list& package_titles, const opts_t& opts);
GDPM_DLL_EXPORT void print_list(const rapidjson::Document& json);
GDPM_DLL_EXPORT void print_list(const info_list& packages);
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);
/* Dependency Management API */
GDPM_DLL_EXPORT result_t<info_list> synchronize_database(const config::context& config, const title_list& package_titles);
GDPM_DLL_EXPORT result_t<info_list> resolve_dependencies(const config::context& config, const title_list& package_titles);
}