Skip to content

Commit

Permalink
add by git url
Browse files Browse the repository at this point in the history
  • Loading branch information
lsproule committed Dec 21, 2023
1 parent 0513866 commit 488a2f2
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 122 deletions.
49 changes: 0 additions & 49 deletions frate-project.json

This file was deleted.

2 changes: 1 addition & 1 deletion src/Command/Actions/Add.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace Frate::Command::Add {
return {
Handler{
.aliases = {"packages","p","package"},
.flags = {"-l,--latest","-m,--mode","-t,--target"},
.flags = {"-l,--latest","-m,--mode","-t,--target", "-pv,--package-version", "-g,--git", "-t,--target-link"},
.positional_args = {"package_name"},
.docs = "Add a package to the project",
.callback = &Packages::add,
Expand Down
3 changes: 1 addition & 2 deletions src/Command/Actions/New.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ bool options(std::shared_ptr<Interface> inter) {
void gitInit(std::shared_ptr<Interface> inter){
Generators::GitIgnore::create(inter);
//TODO: make this work on windows
git_repository *repo = nullptr;
git_repository_init(&repo, inter->pro->path.string().c_str(),0);
Utils::hSystem("git init");
(void)inter;
}

Expand Down
1 change: 0 additions & 1 deletion src/Command/Modes/CommandModes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ namespace Frate:: Command::Modes{

interface->pro->modes.push_back(mode);


return true;
}
bool remove(std::shared_ptr<Interface> inter){
Expand Down
54 changes: 45 additions & 9 deletions src/Command/Package/AddPackages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,63 @@ namespace Frate::Command::Packages {
std::string git = "";
std::string target_link = "";

//TODO: Add support for multiple dependencies
if (inter->args->count("args") == 0) {
Utils::error << "No packages specified" << std::endl;
return false;
}

if (inter->args->count("mode") != 0){
mode = inter->args->operator[]("mode").as<std::string>();
}
if (inter->args->count("git") != 0) {
git = inter->args->operator[]("args").as<std::string>();
git = inter->args->operator[]("git").as<std::string>();
}
if (inter->args->count("version") != 0) {
version = inter->args->operator[]("version").as<std::string>();
if (inter->args->count("package-version") != 0) {
version = inter->args->operator[]("package-version").as<std::string>();
}
if (inter->args->count("target_link") != 0) {
target_link = inter->args->operator[]("target_link").as<std::string>();
}

if(inter->args->operator[]("latest").as<bool>()){
latest = true;
}
if (git != "") {
std::cout << "Adding git package" << std::endl;
std::cout << "Git: " << git << std::endl;
std::cout << "Version: " << version << std::endl;
Utils::info << "Adding git package" << std::endl;
if (version == "") {
Utils::error << "No version specified" << std::endl;
Utils::error << "Please specify a version" << std::endl;
return false;
}
if (target_link == "") {
Prompt target_link_prompt("Specify target_link: ");
target_link_prompt.run();
auto [valid, target_link] = target_link_prompt.get<std::string>();
if (!valid) {
Utils::error << "Failed to get target_link" << std::endl;
return false;
}
}
Package package;
package.name = git;
package.selected_version = version;
package.target_link = target_link;
package.git = git;
package.versions.push_back(version);
if (mode != "") {
if (!addPackageToMode(inter, package, mode)) {
Utils::error << "Failed to add package to mode" << std::endl;
return false;
}
return true;
}
std::cout << "Package: " << nlohmann::json(package) << std::endl;
inter->pro->dependencies.push_back(package);
if (!inter->pro->save()){
Utils::error << "Failed to save project" << std::endl;
return false;
};
return true;
}


std::vector<std::string> package_names = inter->args->operator[]("args").as<std::vector<std::string>>();
for (std::string package_name : package_names) {
Expand Down
61 changes: 1 addition & 60 deletions src/Command/Package/Package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Frate::Command::Packages {
("m,mode", "make changes to compile mode", cxxopts::value<std::string>())
//TODO: make git version, and stuff like that work to make packages more relaxed
("g,git", "git repo to clone", cxxopts::value<std::string>())
("v,version", "version for package", cxxopts::value<std::string>())
("package-version", "version for package", cxxopts::value<std::string>())
("t,target_link", "how to link to package", cxxopts::value<std::string>())
("e,exact", "Exact package", cxxopts::value<bool>()->default_value("false"))
("l,latest", "Latest package", cxxopts::value<bool>()->default_value("false"))
Expand Down Expand Up @@ -51,62 +51,3 @@ namespace Frate::Command::Packages {

}


namespace Frate::Command {
using nlohmann::json;

// json Package::toJson() {
// json data;
// data["name"] = this->name;
// data["versions"] = this->versions;
// 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;
// }
//
// void Package::fromJson(json data) {
// this->name = data["name"];
//
// if(data["versions"].is_null()){
// this->versions = {"master"};
// }else{
// this->versions = data["versions"];
// }
//
// this->description = data["description"];
//
// if(target_link == ""){
// this->target_link = this->name;
// }else{
// 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<int>();
// this->forks = data["forks"].get<int>();
// this->open_issues = data["open_issues"].get<int>();
// this->watchers = data["watchers"].get<int>();
//
// }

}

0 comments on commit 488a2f2

Please sign in to comment.