aboutsummaryrefslogtreecommitdiff
path: root/src/create_pkg.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/create_pkg.cc')
-rw-r--r--src/create_pkg.cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/create_pkg.cc b/src/create_pkg.cc
index 5cea49e..564c11f 100644
--- a/src/create_pkg.cc
+++ b/src/create_pkg.cc
@@ -1,18 +1,31 @@
+#include <iostream>
#include <string>
#include <filesystem>
-#include "vars.cc"
-#include "name_from_url.cc"
+#include "create_pkg.hh"
+#include "name_from_url.hh"
+#include "vars.hh"
Pkg create_pkg(std::string arg) {
Pkg pkg;
+ bool is_in_repos = false;
+
+ for (auto repo : repos) {
+ if (arg == repo.first) { is_in_repos = true; }
+ }
if (arg.rfind("http", 0) == 0) {
pkg.url = arg;
pkg.name = name_from_url(arg);
} else if (arg == ".") {
pkg.url = "";
- pkg.name = name_from_url(fs::current_path().string());
+ pkg.name = name_from_url(std::filesystem::current_path().string());
+ } else if (is_in_repos) {
+ pkg.url = repos[arg];
+ pkg.name = arg;
+ } else {
+ std::cout << print_error << "'" << arg << "'" << " is not a valid package";
+ exit(1);
}
pkg.ver = "HEAD";