Skip to content

Commit

Permalink
added project type
Browse files Browse the repository at this point in the history
  • Loading branch information
DeaSTL committed Nov 7, 2023
1 parent c9ff583 commit 2e3e12d
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 71 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ if(RELEASE EQUAL 1)
add_definitions(-DRELEASE)
else()
add_definitions(-DDEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -Wextra -Wpedantic -Wall -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -Wextra -Wpedantic -Wall")
if(TEST_MODE EQUAL 1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -Wextra -Wpedantic -Wall")
FetchContent_Declare(
Expand Down
29 changes: 0 additions & 29 deletions install_manifest.txt

This file was deleted.

13 changes: 10 additions & 3 deletions src/Command/Command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ namespace Command {
std::string target_link;
std::string description;
int score;
//TODO: implement this
json toJson();
void fromJson(json j);
} Package;
} Package;//Deez nuts

typedef struct Dependency_s {
std::string name;
Expand All @@ -89,11 +90,17 @@ namespace Command {
int port;
} BuildServer;

namespace ProjectType {
const std::string EXECUTABLE = "executable";
const std::string HEADER_ONLY = "header_only";
const std::string STATIC_LIBRARY = "static_library";
const std::string SHARED_LIBRARY = "shared_library";
};
typedef struct Project_s {
std::string project_name;
std::string project_type;
std::string project_description;
BuildServer build_server;
std::string project_type = ProjectType::EXECUTABLE;
BuildServer build_server;
std::filesystem::path project_path;
std::string git{"null"};
std::string lang{"cpp"};
Expand Down
6 changes: 5 additions & 1 deletion src/Command/CommandInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,12 @@ bool Interface::init() {
if(args->operator[]("name").count() > 0){
new_project_name = args->operator[]("name").as<std::string>();
}

pro->project_name = new_project_name;

if(args->operator[]("type").count() > 0){
pro->project_type = args->operator[]("type").as<std::string>();
std::cout << "type: " << pro->project_type << ENDL;
}
//TODO: Stop using this shit
file_exists(file_name);
if(pro->project_path.empty()){
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Command {
project_name = j["project_name"];
cmake_version = j["cmake_version"];
project_version = j["project_version"];
project_type = j["project_type"];
lang = j["lang"];
lang_version = j["lang_version"];
compiler = j["compiler"];
Expand Down Expand Up @@ -46,6 +47,7 @@ namespace Command {
}
json j;
j["project_name"] = project_name;
j["project_type"] = project_type;
j["cmake_version"] = cmake_version;
j["project_version"] = project_version;
j["lang"] = lang;
Expand Down
3 changes: 2 additions & 1 deletion src/Command/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ namespace Command {
("y,skip-init", "skip init", cxxopts::value<bool>()->default_value("false"))
("v,verbose", "Verbose output", cxxopts::value<bool>()->default_value("false"))
("name", "Name of the project", cxxopts::value<std::string>()->default_value("false"))
("language", "Language of the project", cxxopts::value<std::string>()->default_value("cpp"));
("t,type", "Type of the project", cxxopts::value<std::string>()->default_value(ProjectType::EXECUTABLE))
("l,language", "Language of the project", cxxopts::value<std::string>()->default_value("cpp"));
return inter->parse();
}
bool OptionsInit::Add(Interface* inter) {
Expand Down
4 changes: 1 addition & 3 deletions src/Command/SearchPackage.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#include "Command.hpp"
#include <curl/curl.h>
#include <curl/easy.h>
#include <nlohmann/json.hpp>
#include "../Utils/General.hpp"
#include "../Utils/CLI.hpp"
Expand Down Expand Up @@ -118,7 +116,7 @@ namespace Command {


std::cout << "Results: " << results.size() << std::endl;
Utils::CLI::List *list = (new Utils::CLI::List())->
List *list = (new Utils::CLI::List())->
Numbered()->
ReverseIndexed();
for(Package result: results){
Expand Down
61 changes: 28 additions & 33 deletions src/Generators/ConfigJsonGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,52 @@
#include <termcolor/termcolor.hpp>

namespace Generators::ConfigJson{






bool readUserInput(std::shared_ptr<Command::Project> pro, std::shared_ptr<Config> config_json) {
validateLang:
if(!validateLang("📚Language->" + pro->lang + " : ", pro, config_json)) {
//TODO: Convert this to the new prompt system

while(!validateLang("📚Language->" + pro->lang + " : ", pro, config_json)) {
std::cout << termcolor::red << "Invalid language - retry" << termcolor::reset << std::endl;
goto validateLang;

}
validateProjectName:
if (!validateProjectName("📖Project name->" + pro->project_name + " : ", pro, config_json)) {

while (!validateProjectName("📖Project name->" + pro->project_name + " : ", pro, config_json)) {
std::cout << termcolor::red << "Invalid project name - retry" << termcolor::reset << std::endl;
goto validateProjectName;

}
validateCmakeVersion:
if (!validateCmakeVersion("🔨Cmake version->" + pro->cmake_version + " : ", pro, config_json)) {

while (!validateCmakeVersion("🔨Cmake version->" + pro->cmake_version + " : ", pro, config_json)) {
std::cout << termcolor::red << "Invalid cmake version - retry" << termcolor::reset << std::endl;
goto validateCmakeVersion;

}
validateProjectVersion:
if (!validateProjectVersion("🗃️Version->" + pro->project_version + " : ", pro, config_json)) {

while (!validateProjectVersion("🗃️Version->" + pro->project_version + " : ", pro, config_json)) {
std::cout << termcolor::red << "Invalid project version - retry" << termcolor::reset << std::endl;
goto validateProjectVersion;

}
validateLanguageVersion:
if (!validateLanguageVersion("📰Language Standard->" + pro->lang_version + " : ", pro, config_json)) {

while (!validateLanguageVersion("📰Language Standard->" + pro->lang_version + " : ", pro, config_json)) {
std::cout << termcolor::red << "Invalid language version - retry" << termcolor::reset << std::endl;
goto validateLanguageVersion;

}
validateCompiler:
if (!validateCompiler("💽Compiler->", pro, config_json)) {

while (!validateCompiler("💽Compiler->", pro, config_json)) {
std::cout << termcolor::red << "Invalid compiler - retry" << termcolor::reset << std::endl;
goto validateCompiler;

}
validateSourceDir:
if (!validateSourceDir("⛲Source Dir->" + pro->src_dir + " : ", pro, config_json)) {

while (!validateSourceDir("⛲Source Dir->" + pro->src_dir + " : ", pro, config_json)) {
std::cout << termcolor::red << "Invalid source directory - retry" << termcolor::reset << std::endl;
goto validateSourceDir;

}
validateBuildDir:
if (!validateBuildDir("🛠️Build Dir->" + pro->build_dir + " : ", pro, config_json)) {

while (!validateBuildDir("🛠️Build Dir->" + pro->build_dir + " : ", pro, config_json)) {
std::cout << termcolor::red << "Invalid build directory - retry" << termcolor::reset << std::endl;
goto validateBuildDir;

}
validateIncludeDir:
if (!validateIncludeDir("🫃Include Dir->" + pro->include_dir + " : ", pro, config_json)) {

while (!validateIncludeDir("🫃Include Dir->" + pro->include_dir + " : ", pro, config_json)) {
std::cout << termcolor::red << "Invalid include directory - retry" << termcolor::reset << std::endl;
goto validateIncludeDir;

}
return true;
}
Expand Down

0 comments on commit 2e3e12d

Please sign in to comment.