mirror of
https://github.com/davidallendj/gdpm.git
synced 2025-12-20 03:27:02 -07:00
Fixed installing issue with no set remote
- Added default remote repo - Fixed adding and removing remote repos
This commit is contained in:
parent
8b1f1374d8
commit
996c47466e
6 changed files with 46 additions and 29 deletions
0
src/README.md
Normal file
0
src/README.md
Normal file
|
|
@ -90,6 +90,16 @@ namespace gdpm::package{
|
|||
return error();
|
||||
}
|
||||
|
||||
/* Check if provided param is in remote sources*/
|
||||
if(!config.remote_sources.contains(params.remote_source)){
|
||||
error error(
|
||||
constants::error::NOT_FOUND,
|
||||
"Remote resource not found in config."
|
||||
);
|
||||
log::error(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Try and obtain all requested packages. */
|
||||
std::vector<string_pair> dir_pairs;
|
||||
task_list tasks;
|
||||
|
|
@ -161,7 +171,7 @@ namespace gdpm::package{
|
|||
|
||||
/* Check if we already have a stored temporary file before attempting to download */
|
||||
if(std::filesystem::exists(tmp_zip) && std::filesystem::is_regular_file(tmp_zip)){
|
||||
log::println("Found cached package. Skipping download.", p.title);
|
||||
log::info("Found cached package. Skipping download.", p.title);
|
||||
}
|
||||
else{
|
||||
/* Download all the package files and place them in tmp directory. */
|
||||
|
|
@ -226,7 +236,7 @@ namespace gdpm::package{
|
|||
if(p_cache.empty()){
|
||||
error error(
|
||||
constants::error::NOT_FOUND,
|
||||
"\nCould not find any packages to remove."
|
||||
"Could not find any packages to remove."
|
||||
);
|
||||
log::error(error);
|
||||
return error;
|
||||
|
|
|
|||
|
|
@ -11,14 +11,6 @@ namespace gdpm::remote{
|
|||
const args_t& args,
|
||||
const opts_t& opts
|
||||
){
|
||||
log::println("_handle_remote");
|
||||
for(const auto& arg : args){
|
||||
log::println("arg: {}", arg);
|
||||
}
|
||||
for(const auto& opt : opts){
|
||||
log::println("opt: {}:{}", opt.first, utils::join(opt.second));
|
||||
}
|
||||
|
||||
/* Check if enough arguments are supplied */
|
||||
size_t argc = args.size();
|
||||
if (argc < 1){
|
||||
|
|
@ -28,19 +20,30 @@ namespace gdpm::remote{
|
|||
|
||||
/* Check which subcommand is supplied */
|
||||
string sub_command = args.front();
|
||||
args_t argv(args.begin()+1, args.end());
|
||||
if(argv.size() < 2){
|
||||
error error(
|
||||
constants::error::INVALID_ARGS,
|
||||
"Invalid number of args"
|
||||
);
|
||||
log::error(error);
|
||||
return error;
|
||||
if(sub_command == "add"){
|
||||
if(args.size() < 3 || args.empty()){
|
||||
error error(
|
||||
constants::error::INVALID_ARG_COUNT,
|
||||
"Invalid number of args."
|
||||
);
|
||||
log::error(error);
|
||||
return error;
|
||||
}
|
||||
string name = args[1];
|
||||
string url = args[2];
|
||||
add_repositories(config, {{name, url}});
|
||||
}
|
||||
else if (sub_command == "remove") {
|
||||
if(args.size() < 2 || args.empty()){
|
||||
error error(
|
||||
constants::error::INVALID_ARG_COUNT,
|
||||
"Invalid number of args."
|
||||
);
|
||||
log::error(error);
|
||||
return error;
|
||||
}
|
||||
remove_respositories(config, {args.begin()+1, args.end()});
|
||||
}
|
||||
string name = argv[1];
|
||||
string url = argv[2];
|
||||
if(sub_command == "add") add_repositories(config, {{name, url}});
|
||||
else if (sub_command == "remove") remove_respositories(config, argv);
|
||||
// else if (sub_command == "set") set_repositories(config::context &context, const repository_map &repos)
|
||||
else if (sub_command == "list") print_repositories(config);
|
||||
else{
|
||||
|
|
@ -79,9 +82,12 @@ namespace gdpm::remote{
|
|||
config::context& config,
|
||||
const repo_names& names
|
||||
){
|
||||
std::for_each(names.end(), names.begin(), [&config](const string& repo){
|
||||
config.remote_sources.erase(repo);
|
||||
});
|
||||
for(auto it = names.begin(); it != names.end();){
|
||||
if(config.remote_sources.contains(*it)){
|
||||
config.remote_sources.erase(*it);
|
||||
}
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -94,10 +100,9 @@ namespace gdpm::remote{
|
|||
}
|
||||
|
||||
void print_repositories(const config::context& config){
|
||||
log::println("Remote sources:");
|
||||
const auto &rs = config.remote_sources;
|
||||
std::for_each(rs.begin(), rs.end(), [](const string_pair& p){
|
||||
log::println("\t{}: {}", p.first, p.second);
|
||||
log::println("{}: {}", p.first, p.second);
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue