Fixed minor issues and typos

This commit is contained in:
David Allen 2023-07-01 23:23:14 -06:00
parent 0c9e07f946
commit fa22c1d452
4 changed files with 90 additions and 64 deletions

View file

@ -198,13 +198,13 @@ Installation behavior can be adjusted using other flags like `--disable-sync`, `
```bash ```bash
gdpm install "Flappy Godot" "GodotNetworking" -y gdpm install "Flappy Godot" "GodotNetworking" -y
gdpm install -f packages.txt --config config.json --no-sync --skip-prompt --verbose gdpm install -f packages.txt --config config.json --disable-sync --skip-prompt --verbose
gdpm export path/to/packages.txt gdpm export path/to/packages.txt
gdpm install -f path/to/packages.txt --disable-sync --skip-prompt gdpm install -f path/to/packages.txt --disable-sync --skip-prompt
# Future work for multithreading support... # Future work for multithreading support...
# gdpm install -f path/to/packages.txt -j$(nproc) --no-sync --skip-prompt --verbose # gdpm install -f path/to/packages.txt -j$(nproc) --disable-sync --skip-prompt --verbose
``` ```
Packages can be removed similiarly to installing. Packages can be removed similiarly to installing.
@ -238,13 +238,12 @@ Search for available packages using the `search` command. The results can be twe
Use the `search` command to find a list of available packages. (Note: This currently will only search remotely for package information! This will be changed later to only search the local metadata instead.) Use the `search` command to find a list of available packages. (Note: This currently will only search remotely for package information! This will be changed later to only search the local metadata instead.)
```bash ```bash
gdpm search "GodotNetworking" \ gdpm --verbose search "GodotNetworking" \
--sort updated \ --sort updated \
--type project \ --type project \
--max-results 50 \ --max-results 50 \
--godot-version 3.4 \ --godot-version 3.4 \
--verbose \ --author godot \
--user towk \
--support official --support official
``` ```
@ -253,9 +252,8 @@ gdpm search "GodotNetworking" \
Link an installed package using the `link` command or make copy of it using `clone`. Link an installed package using the `link` command or make copy of it using `clone`.
```bash ```bash
gdpm link "GodotNetworking" tests/test-godot-project gdpm link GodotNetworking tests/test-godot-project
gdpm link -f packages.txt tests/test-godot-project gdpm clone GodotNetworking tests/tests-godot-project/addons
gdpm clone -f packages.txt tests/tests-godot-project/addons
# Future work # Future work
# gdpm link --all # links all installed packages to current directory # gdpm link --all # links all installed packages to current directory

View file

@ -121,7 +121,7 @@ namespace gdpm::package {
GDPM_DLL_EXPORT result_t<title_list> get_package_titles(const info_list& packages); 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); GDPM_DLL_EXPORT void clean_temporary(const config::context& config, const title_list& package_titles);
GDPM_DLL_EXPORT params make_params(const var_args& args, const var_opts& opts); GDPM_DLL_EXPORT params make_params(const var_args& args, const var_opts& opts);
GDPM_DLL_EXPORT void read_file(title_list& package_titles, const path_list& paths);
/* Dependency Management API */ /* 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> 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); GDPM_DLL_EXPORT result_t<info_list> resolve_dependencies(const config::context& config, const title_list& package_titles);

View file

@ -40,18 +40,8 @@ namespace gdpm::package{
*/ */
/* Append files from --file option */ /* Append files from --file option */
// if(!params.input_files.empty()){ read_file(package_titles, params.input_files);
for(const auto& filepath : params.input_files){
string contents = utils::readfile(filepath);
log::print("contents: {}", contents);
string_list input_titles = utils::split_lines(contents);
package_titles.insert(
std::end(package_titles),
std::begin(input_titles),
std::end(input_titles)
);
}
// }
result_t result = cache::get_package_info_by_title(package_titles); result_t result = cache::get_package_info_by_title(package_titles);
package::info_list p_found = {}; package::info_list p_found = {};
package::info_list p_cache = result.unwrap_unsafe(); package::info_list p_cache = result.unwrap_unsafe();
@ -250,17 +240,7 @@ namespace gdpm::package{
/* Append package titles from --file option */ /* Append package titles from --file option */
if(!params.input_files.empty()){ read_file(package_titles, params.input_files);
for(const auto& filepath : params.input_files){
string contents = utils::readfile(filepath);
string_list _package_titles = utils::split_lines(contents);
package_titles.insert(
std::end(package_titles),
std::begin(_package_titles),
std::end(_package_titles)
);
}
}
/* Find the packages to remove if they're is_installed and show them to the user */ /* Find the packages to remove if they're is_installed and show them to the user */
result_t result = cache::get_package_info_by_title(package_titles); result_t result = cache::get_package_info_by_title(package_titles);
@ -563,19 +543,17 @@ namespace gdpm::package{
} }
if(p_found.empty()){ if(p_found.empty()){
error error( return log::error_rc(error(
constants::error::NO_PACKAGE_FOUND, constants::error::NO_PACKAGE_FOUND,
"No packages found to link." "No packages found to link."
); ));
log::error(error);
return error;
} }
/* Get the storage paths for all packages to create symlinks */ /* Get the storage paths for all packages to create symlinks */
const path package_dir{config.packages_dir}; const path package_dir{config.packages_dir};
for(const auto& p : p_found){ for(const auto& p : p_found){
for(const auto& path : params.paths){ for(const auto& path : params.paths){
log::info_n("link: \"{}\" -> '{}'...", p.title, path + "/" + p.title); log::println("link: \"{}\" -> '{}'...", p.title, path + "/" + p.title);
// std::filesystem::path target{config.packages_dir + "/" + p.title}; // std::filesystem::path target{config.packages_dir + "/" + p.title};
std::filesystem::path target = {current_path().string() + "/" + config.packages_dir + "/" + p.title}; std::filesystem::path target = {current_path().string() + "/" + config.packages_dir + "/" + p.title};
std::filesystem::path symlink_path{path + "/" + p.title}; std::filesystem::path symlink_path{path + "/" + p.title};
@ -584,13 +562,11 @@ namespace gdpm::package{
std::error_code ec; std::error_code ec;
std::filesystem::create_directory_symlink(target, symlink_path, ec); std::filesystem::create_directory_symlink(target, symlink_path, ec);
if(ec){ if(ec){
error error( log::error(error(
constants::error::STD_ERR, constants::error::STD_ERR,
std::format("Could not create symlink: {}", ec.message()) std::format("Could not create symlink: {}", ec.message())
); ));
log::error(error);
} }
log::println("Done.");
} }
} }
return error(); return error();
@ -645,15 +621,13 @@ namespace gdpm::package{
} }
/* Get the storage paths for all packages to create clones */ /* Get the storage paths for all packages to create clones */
path_refs paths = path_refs{params.args.back()};
// path_list paths = path_list({params.args.back()}); // path_list paths = path_list({params.args.back()});
const path package_dir{config.packages_dir}; const path package_dir{config.packages_dir};
for(const auto& p : p_found){ for(const auto& p : p_found){
for(const auto& path : paths){ for(const auto& path : params.paths){
const string _path = string(path); log::println("clone: \"{}\" -> {}", p.title, path + "/" + p.title);
log::info("clone: \"{}\" -> {}", p.title, _path + "/" + p.title);
std::filesystem::path from{config.packages_dir + "/" + p.title}; std::filesystem::path from{config.packages_dir + "/" + p.title};
std::filesystem::path to{_path + "/" + p.title}; std::filesystem::path to{path + "/" + p.title};
if(!std::filesystem::exists(to.string())) if(!std::filesystem::exists(to.string()))
std::filesystem::create_directories(to); /* This should only occur if using a --force flag */ std::filesystem::create_directories(to); /* This should only occur if using a --force flag */
@ -898,6 +872,21 @@ namespace gdpm::package{
return result_t(p_deps, error()); return result_t(p_deps, error());
} }
void read_file(
title_list& package_titles,
const path_list& paths
){
for(const auto& filepath : paths){
string contents = utils::readfile(filepath);
title_list input_titles = utils::split_lines(contents);
package_titles.insert(
std::end(package_titles),
std::begin(input_titles),
std::end(input_titles)
);
}
}
string to_json( string to_json(
const info& info, const info& info,
bool pretty_pretty bool pretty_pretty

View file

@ -148,7 +148,7 @@ namespace gdpm::package_manager{
install_command.add_description("install package(s)"); install_command.add_description("install package(s)");
install_command.add_argument("packages") install_command.add_argument("packages")
.required() .required()
.nargs(nargs_pattern::at_least_one) .nargs(nargs_pattern::any)
.help("packages to install"); .help("packages to install");
install_command.add_argument("--godot-version") install_command.add_argument("--godot-version")
.help("set Godot version for request"); .help("set Godot version for request");
@ -205,7 +205,8 @@ namespace gdpm::package_manager{
.nargs(nargs_pattern::at_least_one); .nargs(nargs_pattern::at_least_one);
remove_command.add_description("remove package(s)"); remove_command.add_description("remove package(s)");
remove_command.add_argument("packages").nargs(nargs_pattern::at_least_one); remove_command.add_argument("packages")
.nargs(nargs_pattern::any);
remove_command.add_argument("--clean"); remove_command.add_argument("--clean");
remove_command.add_argument("-y", "--skip-prompt"); remove_command.add_argument("-y", "--skip-prompt");
remove_command.add_argument("-f", "--file") remove_command.add_argument("-f", "--file")
@ -214,7 +215,8 @@ namespace gdpm::package_manager{
.nargs(nargs_pattern::at_least_one); .nargs(nargs_pattern::at_least_one);
update_command.add_description("update package(s)"); update_command.add_description("update package(s)");
update_command.add_argument("packages").nargs(nargs_pattern::at_least_one); update_command.add_argument("packages")
.nargs(nargs_pattern::any);
update_command.add_argument("--clean"); update_command.add_argument("--clean");
update_command.add_argument("--remote"); update_command.add_argument("--remote");
update_command.add_argument("-f", "--file") update_command.add_argument("-f", "--file")
@ -223,9 +225,30 @@ namespace gdpm::package_manager{
.nargs(nargs_pattern::at_least_one); .nargs(nargs_pattern::at_least_one);
search_command.add_description("search for package(s)"); search_command.add_description("search for package(s)");
search_command.add_argument("packages").nargs(nargs_pattern::at_least_one); search_command.add_argument("packages")
search_command.add_argument("--godot-version"); .nargs(nargs_pattern::any);
search_command.add_argument("--remote"); search_command.add_argument("--godot-version")
.help("set Godot version")
.nargs(1);
search_command.add_argument("--remote")
.help("set remote to use")
.nargs(1);
search_command.add_argument("--sort")
.help("sort the results")
.nargs(1);
search_command.add_argument("--type")
.help("set the asset type")
.nargs(1);
search_command.add_argument("--max-results")
.help("limit the results")
.nargs(1);
search_command.add_argument("--author")
.help("set the asset author")
.nargs(1);
search_command.add_argument("--support")
.help("set the support level")
.nargs(1);
search_command.add_argument("-f", "--file") search_command.add_argument("-f", "--file")
.help("set the file(s) to read as input") .help("set the file(s) to read as input")
.append() .append()
@ -254,21 +277,29 @@ namespace gdpm::package_manager{
link_command.add_description("link package(s) to path"); link_command.add_description("link package(s) to path");
link_command.add_argument("packages") link_command.add_argument("packages")
.help("package(s) to link") .help("package(s) to link")
.required()
.nargs(1); .nargs(1);
link_command.add_argument("path") link_command.add_argument("path")
.help("path to link") .help("path to link")
.required() .nargs(1);
link_command.add_argument("-f", "--file")
.help("files to link")
.nargs(nargs_pattern::at_least_one);
link_command.add_argument("-p", "--path")
.help("set path to link")
.nargs(1); .nargs(1);
clone_command.add_description("clone package(s) to path"); clone_command.add_description("clone package(s) to path");
clone_command.add_argument("packages") clone_command.add_argument("packages")
.help("package(s) to clone") .help("package(s) to clone")
.required()
.nargs(1);; .nargs(1);;
clone_command.add_argument("path") clone_command.add_argument("path")
.help("path to clone") .help("path to clone")
.required() .nargs(1);
clone_command.add_argument("-f", "--file")
.help("file")
.nargs(nargs_pattern::at_least_one);
clone_command.add_argument("-p", "--path")
.help("set path to clone")
.nargs(1); .nargs(1);
clean_command.add_description("clean package(s) temporary files"); clean_command.add_description("clean package(s) temporary files");
@ -280,8 +311,7 @@ namespace gdpm::package_manager{
fetch_command.add_description("fetch and sync asset data"); fetch_command.add_description("fetch and sync asset data");
fetch_command.add_argument("remote") fetch_command.add_argument("remote")
.help("remote to fetch") .help("remote to fetch")
.required() .nargs(nargs_pattern::any);
.nargs(1);
config_get.add_argument("properties") config_get.add_argument("properties")
.help("get config properties") .help("get config properties")
@ -379,7 +409,7 @@ namespace gdpm::package_manager{
} }
else if(program.is_subcommand_used(update_command)){ else if(program.is_subcommand_used(update_command)){
action = action_e::update; action = action_e::update;
package_titles = get_packages_from_parser(program); package_titles = get_packages_from_parser(update_command);
set_if_used(update_command, config.clean_temporary, "clean"); set_if_used(update_command, config.clean_temporary, "clean");
set_if_used(update_command, params.remote_source, "remote"); set_if_used(update_command, params.remote_source, "remote");
set_if_used(update_command, params.input_files, "file"); set_if_used(update_command, params.input_files, "file");
@ -397,7 +427,6 @@ namespace gdpm::package_manager{
} }
else if(program.is_subcommand_used(list_command)){ else if(program.is_subcommand_used(list_command)){
action = action_e::list; action = action_e::list;
// auto list = get_parser(program, "list");
if(list_command.is_used("show")) if(list_command.is_used("show"))
params.args = list_command.get<string_list>("show"); params.args = list_command.get<string_list>("show");
if(list_command.is_used("style")){ if(list_command.is_used("style")){
@ -412,11 +441,23 @@ namespace gdpm::package_manager{
action = action_e::link; action = action_e::link;
package_titles = get_packages_from_parser(link_command); package_titles = get_packages_from_parser(link_command);
set_if_used(link_command, params.paths, "path"); set_if_used(link_command, params.paths, "path");
if(link_command.is_used("file")){
params.input_files = link_command.get<string_list>("file");
}
if(link_command.is_used("path")){
params.paths = link_command.get<string_list>("path");
}
} }
else if(program.is_subcommand_used(clone_command)){ else if(program.is_subcommand_used(clone_command)){
action = action_e::clone; action = action_e::clone;
package_titles = get_packages_from_parser(clone_command); package_titles = get_packages_from_parser(clone_command);
set_if_used(clone_command, params.paths, "path"); set_if_used(clone_command, params.paths, "path");
if(clone_command.is_used("file")){
params.input_files = clone_command.get<string_list>("file");
}
if(clone_command.is_used("path")){
params.paths = clone_command.get<string_list>("path");
}
} }
else if(program.is_subcommand_used(clean_command)){ else if(program.is_subcommand_used(clean_command)){
action = action_e::clean; action = action_e::clean;
@ -435,13 +476,11 @@ namespace gdpm::package_manager{
if(config_set.is_used("value")) if(config_set.is_used("value"))
params.args.emplace_back(config_set.get<string>("value")); params.args.emplace_back(config_set.get<string>("value"));
} }
// else{
// action = action_e::config_get;
// }
} }
else if(program.is_subcommand_used(fetch_command)){ else if(program.is_subcommand_used(fetch_command)){
action = action_e::fetch; action = action_e::fetch;
params.remote_source = fetch_command.get("remote"); if(fetch_command.is_used("remote"))
params.remote_source = fetch_command.get("remote");
} }
else if(program.is_subcommand_used(version_command)){ else if(program.is_subcommand_used(version_command)){
action = action_e::version; action = action_e::version;