Skip to content

Commit

Permalink
updated reflections
Browse files Browse the repository at this point in the history
  • Loading branch information
DeaSTL committed Dec 19, 2023
1 parent 6141492 commit 5ac8184
Show file tree
Hide file tree
Showing 50 changed files with 813 additions and 607 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ CPMAddPackage(
OPTIONS
"BUILD_STATIC_LIBS ON"
"JSON_BuildTests OFF"
"JSON_Diagnostics ON"


)
Expand Down
2 changes: 1 addition & 1 deletion build
Submodule build updated from 1327ae to 0c2346
49 changes: 49 additions & 0 deletions frate-project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"authors": [],
"build_dir": "build",
"cmake_version": "3.10",
"compiler": "g++",
"default_mode": "Release",
"dependencies": [],
"flags": [
"-O3"
],
"git": "null",
"homepage": "null",
"include_dir": "include",
"keywords": [],
"lang": "cpp",
"lang_version": "20",
"libs": [],
"modes": [
{
"dependencies": [],
"flags": [
"-O2"
],
"name": "Release"
},
{
"dependencies": [],
"flags": [
"-g"
],
"name": "Debug"
},
{
"dependencies": [],
"flags": [
"-g"
],
"name": "Test"
}
],
"project_description": "",
"project_name": "debug-frate",
"project_type": "executable",
"project_version": "0.0.1",
"prompts": {},
"src_dir": "src",
"toolchains": [],
"variables": {}
}
248 changes: 141 additions & 107 deletions include/Frate/Command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,35 @@ namespace Frate::Command {
using namespace Utils::CLI::Ansi;
using namespace cxxopts;

class Package {
public:
std::string name;
std::string git;
std::string git_short;
std::string git_prefixed;
std::vector<std::string> 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);
bool addCallback(sol::state &lua);
friend void from_json(const json &j, Package& package);
friend void to_json(json &j, const Package& package);
Package(){};
};

/*
* Package structure from index
* @param name the name of the package
* @param url the url of the package
* @param versions the versions of the package
* @param target_link the target link of the package
* @param description the description of the package
* @param score the score of the package, used for sorting
*/
typedef struct Package_s {
std::string name;
std::string git;
std::string git_short;
std::string git_prefixed;
std::vector<std::string> 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);
bool addCallback(sol::state &lua);
} Package;//Deez nuts

typedef struct RemoteServer{
typedef struct RemoteServer_s{
std::string name;
std::string ip;
std::string username;
Expand All @@ -76,82 +70,121 @@ namespace Frate::Command {
}
};

typedef struct Mode{
std::string name;
std::vector<std::string> flags;
std::vector<Package> dependencies{};
} Mode;

typedef struct ProjectPrompt_s {
std::string value{""};
std::string text{""};
std::string type{"string"};
// std::string key{""};
std::string default_value{""};
bool required{false};
std::vector<std::string> options{};
std::function<bool(std::string)> validator{
[this](std::string s) -> bool {
if(options.size() == 0) {
return true;
}else{
for (std::string option: options){
if (s == option){
return true;
class Mode{
public:
std::string name;
std::vector<std::string> flags;
std::vector<Package> dependencies{};
friend void from_json(const json &j, Mode& mode);
friend void to_json(json &j, const Mode& mode);
Mode(std::string name = "", std::vector<std::string> flags = {}, std::vector<Package> dependencies = {});
};

class ProjectPrompt{
public:
ProjectPrompt(){};
std::string value{""};
std::string text{""};
std::string type{"string"};
std::string default_value{""};
bool required{false};
std::vector<std::string> options{};
friend void from_json(const json &j, ProjectPrompt& prompt);
friend void to_json(json &j, const ProjectPrompt& prompt);
std::function<bool(std::string)> validator{
[this](std::string s) -> bool {
if(options.size() == 0) {
return true;
}else{
for (std::string option: options){
if (s == option){
return true;
}
}
return false;
}
return false;
}
}
};
template<typename T>
T get();
} ProjectPrompt;
};
template<typename T>
T get();
};

//TODO: MAKE MOST OF THESE OPTIONAL
typedef struct Project_s {
std::string name;
std::string description;
std::string type{""};
RemoteServer build_server;
std::filesystem::path path;
std::string git{"null"};
std::string homepage{"null"};
std::string bugs{"null"};
std::string lang{"cpp"};
std::string cmake_version{"3.28"};
std::string lang_version{"20"};
std::string compiler{"g++"};
std::string license{""};
std::string default_mode{"Release"};
std::string build_command;
std::vector<Mode> modes{
Mode{.name = "Release", .flags={"-O2 "}},
Mode{.name= "Debug", .flags= {"-g"}},
Mode{.name= "Test", .flags={"-g"}}
};
std::vector<std::string> authors;
std::vector<std::string> keywords;
std::string src_dir{"src"};
std::string include_dir{"include"};
std::vector<RemoteServer> build_servers;
std::vector<Package> dependencies;
std::string build_dir{"build"};
Package testing_lib;
std::string version{"0.0.1"};
std::vector<std::string> flags;
std::vector<std::string> toolchains {};
std::vector<std::string> libs{};
void fromJson(json j);
nlohmann::json toJson();
bool save();
void checkKeys(json j);
std::string getPath(){
return path.string();
};
std::unordered_map<std::string,ProjectPrompt> prompts{};
std::unordered_map<std::string,json> variables{};
} Project;
class Template;
class Project {
public:
Project();
std::string name;
std::string description;
std::string type{""};
RemoteServer build_server;
std::filesystem::path path;
std::string git{"null"};
std::string homepage{"null"};
std::string bugs{"null"};
std::string lang{"cpp"};
std::string cmake_version{"3.28"};
std::string lang_version{"20"};
std::string compiler{"g++"};
std::string license{""};
std::string default_mode{"Release"};
std::string build_command{"cmake --build ."};
std::vector<Mode> modes{
Mode("Release",{"-O2"}),
Mode("Debug",{"-g"}),
Mode("Test",{"-g"})
};
std::vector<std::string> authors{};
std::vector<std::string> keywords{};
std::string src_dir{"src"};
std::string include_dir{"include"};
std::vector<RemoteServer> build_servers{};
std::vector<Package> dependencies{};
std::string build_dir{"build"};
Package testing_lib;
std::string version{"0.0.1"};
std::vector<std::string> flags{};
std::vector<std::string> toolchains {};
std::vector<std::string> libs{};
//void fromJson(json j);
//nlohmann::json toJson();
bool save();
void checkKeys(json j);
std::string getPath(){
return path.string();
};
std::unordered_map<std::string,ProjectPrompt> prompts{};
std::unordered_map<std::string,json> variables{};
friend void from_json(const json &j, Project& pro);
friend void to_json(json &j, const Project& pro);
void fromTemplate(Template &t);
};
class Template {
public:
Template();
std::string name;
std::string description;
std::string version;
std::string src_dir{"src"};
std::string include_dir{"include"};
std::string build_dir{"build"};
std::vector<Package> dependencies{};
std::string default_mode{"Release"};
std::vector<Mode> modes{};
std::vector<std::string> flags{};
std::vector<std::string> system_libs{};
std::vector<std::string> supported_toolchains{};
std::vector<std::string> supported_languages{};
std::vector<std::string> supported_language_versions{};
std::string min_cmake_version{"3.10"};
std::vector<std::string> supported_compilers{};
std::vector<std::string> keywords{};
std::unordered_map<std::string,ProjectPrompt> prompts{};
std::unordered_map<std::string,json> variables{};
friend void from_json(const json &j, Template& t);
friend void to_json(json &j, const Template& t);
friend void to_project(Project &pro, const Template &t);
};


typedef struct Handler_s Handler;
Expand Down Expand Up @@ -180,7 +213,7 @@ namespace Frate::Command {
Interface(int argc, char **argv);
void getHelpString(std::string name,std::vector<Handler> &handlers,bool is_subcommand = false);
void getHelpString(Handler &handler);
bool runCommand(std::string,std::vector<Handler>&);
//bool runCommand(std::string,std::vector<Handler>&);
std::shared_ptr<Project> pro;
bool project_present{false};
//bool verbose{false};
Expand All @@ -195,7 +228,7 @@ namespace Frate::Command {
bool confirm_all{false};
bool InitHeader();
bool CreateCMakelists();
bool LoadProjectJson();
bool loadProjectJson();
~Interface();
};

Expand All @@ -212,4 +245,5 @@ namespace Frate::Command {

bool updateIndex();

bool runCommand(std::shared_ptr<Interface> inter,std::string command, std::vector<Handler> &handlers);
}
1 change: 1 addition & 0 deletions include/Frate/Constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace Frate::Constants {
constexpr const std::string_view FRATE_TEMPLATES = "https://github.com/frate-templates/templates/releases/latest/download/index.json";

const std::string TEMPLATE_PATH = "template/";
const std::string TEMPLATE_CALLBACKS_PATH = "frate-callbacks/";
const std::string INIT_SCRIPTS_PATH = "__init__/";
const std::string POST_SCRIPTS_PATH = "__post__/";

Expand Down
Loading

0 comments on commit 5ac8184

Please sign in to comment.