diff --git a/src/Command/Command.hpp b/src/Command/Command.hpp index 8d67116..4750351 100644 --- a/src/Command/Command.hpp +++ b/src/Command/Command.hpp @@ -72,10 +72,21 @@ namespace Command { typedef struct Package_s { std::string name; std::string git; + std::string git_short; + std::string git_prefixed; std::vector versions; std::string target_link; std::string description; std::string selected_version; + std::string git_description; + std::string language; + std::string license; + std::string owner; + std::string owner_type; + int stars; + int forks; + int open_issues; + int watchers; int score; json toJson(); void fromJson(json j); diff --git a/src/Command/CommandGeneral.cpp b/src/Command/CommandGeneral.cpp index 5c83074..9ac3485 100644 --- a/src/Command/CommandGeneral.cpp +++ b/src/Command/CommandGeneral.cpp @@ -9,7 +9,6 @@ namespace Command { std::fstream file; std::string file_name = "config.json"; try { - std::cout << "Project path: " << pro->project_path << std::endl; file.open((pro->project_path / file_name).string()); json data = json::parse(file); pro->fromJson(data); diff --git a/src/Command/CommandUpdate.cpp b/src/Command/CommandUpdate.cpp index dab5004..e67745e 100644 --- a/src/Command/CommandUpdate.cpp +++ b/src/Command/CommandUpdate.cpp @@ -9,7 +9,11 @@ namespace Command { using nlohmann::json; bool Interface::update() { - if (this->args->operator[]("subcommand").as() == "packages") { + if(this->args->count("subcommand") == 0){ + std::cout << "Usage: update (index)" << ENDL; + return true; + } + if (this->args->operator[]("subcommand").as() == "index") { std::cout << "Updating packages" << ENDL; updateIndex(); } diff --git a/src/Command/Package.cpp b/src/Command/Package.cpp index e00c7cc..ca91a94 100644 --- a/src/Command/Package.cpp +++ b/src/Command/Package.cpp @@ -11,6 +11,18 @@ namespace Command { data["description"] = this->description; data["target_link"] = this->target_link; data["git"] = this->git; + data["git_short"] = this->git_short; + data["git_prefixed"] = this->git_prefixed; + data["selected_version"] = this->selected_version; + data["git_description"] = this->git_description; + data["language"] = this->language; + data["license"] = this->license; + data["owner"] = this->owner; + data["owner_type"] = this->owner_type; + data["stars"] = this->stars; + data["forks"] = this->forks; + data["open_issues"] = this->open_issues; + data["watchers"] = this->watchers; return data; } @@ -31,7 +43,20 @@ namespace Command { this->target_link = data["target_link"]; } + this->git = data["git"]; + this->git_short = data["git_short"]; + this->git_prefixed = data["git_prefixed"]; + this->git_description = data["git_description"]; + this->language = data["language"]; + this->license = data["license"]; + this->owner = data["owner"]; + this->owner_type = data["owner_type"]; + this->stars = data["stars"].get(); + this->forks = data["forks"].get(); + this->open_issues = data["open_issues"].get(); + this->watchers = data["watchers"].get(); + } } // namespace Command diff --git a/src/Command/SearchPackage.cpp b/src/Command/SearchPackage.cpp index e715d8c..8d3654b 100644 --- a/src/Command/SearchPackage.cpp +++ b/src/Command/SearchPackage.cpp @@ -74,6 +74,7 @@ namespace Command { void getPackageScore(Package &package, std::string &query){ int score = 0; score += getStringScore(package.name, query) * 10; + score += package.stars / 100; score += getStringScore(package.description, query); score += getStringScore(package.target_link, query); package.score = score; @@ -112,11 +113,15 @@ namespace Command { results.begin(), results.end(), 0, [](int a, Package b){ return a + b.score; }); + int averageScore = totalScore / results.size(); - auto filterResults = results | std::views::filter([&averageScore](Package package){return package.score > 2 * averageScore;}); + auto filterResults = results | std::views::filter( + [&averageScore](Package package){ + return package.score > 2 * averageScore; + }); return std::vector(filterResults.begin(), filterResults.end()); } diff --git a/src/main.cpp b/src/main.cpp index 5f29c51..80631fd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,6 +15,7 @@ #endif int main(int argc, char **argv) { + // LUCAS MAKE SURE YOU INITIALIZE YOUR FUCKING STRUCT YOU TWAT //std::shared_ptr ctx = std::make_shared(); #ifdef TEST