diff --git a/thegreatsitegenerator/CMakeLists.txt b/thegreatsitegenerator/CMakeLists.txt index 2bf8ec0..8b8d5c7 100644 --- a/thegreatsitegenerator/CMakeLists.txt +++ b/thegreatsitegenerator/CMakeLists.txt @@ -4,6 +4,8 @@ cmake_minimum_required(VERSION 3.10) # Name of the project project(TGSG VERSION 0.1) +configure_file(TGSGConfig.h.in TGSGConfig.h) + # Build for C++17 set(CMAKE_CXX_STANDARD 17) @@ -21,11 +23,11 @@ enable_testing() add_executable( tgsg - reading-test.cpp + main.cpp ) target_link_libraries( tgsg - gtest_main + gtest_main ) -include(GoogleTest) -gtest_discover_tests(tgsg) +#include(GoogleTest) +#gtest_discover_tests(tgsg) diff --git a/thegreatsitegenerator/main.cpp b/thegreatsitegenerator/main.cpp index 39ccce4..add8e1f 100644 --- a/thegreatsitegenerator/main.cpp +++ b/thegreatsitegenerator/main.cpp @@ -11,6 +11,10 @@ using namespace std; int main(int argc, const char** argv) { + if (argc != 2) { + cerr << "Type -h for more details.\n"; // Identify user + return 1; + } Reading r; if (argv[1] == "-h"sv || argv[1] == "--help"sv) { cout << "Please type -i followed by the name of the the text file or " @@ -25,8 +29,7 @@ int main(int argc, const char** argv) if (argv[3]) { if (argv[3] == "-l"sv || argv[3] == "--lang"sv) { if (argv[4] && (argv[4] == "en-ca"sv || argv[4] == "pt-br"sv || argv[4] == "fr"sv)) { - lang = argv[4]; - hasLang = true; + r.setLang(argv[4]); } else { cerr << "Please enter a valid language. Type -h for more details.\n"; @@ -79,9 +82,6 @@ int main(int argc, const char** argv) << "Please enter a valid file name. Type -h for more details.\n"; // Identify user return 1; } - } else { - cerr << "Type -h for more details.\n"; // Identify user - return 1; } return 0; } \ No newline at end of file diff --git a/thegreatsitegenerator/reading.h b/thegreatsitegenerator/reading.h index e78a5c0..53d0a45 100644 --- a/thegreatsitegenerator/reading.h +++ b/thegreatsitegenerator/reading.h @@ -6,14 +6,22 @@ #include using namespace std; -bool hasLang; -const char* lang; class Reading { +private: + bool hasLang; + const char* lang; + public: void readFile(string fname, int type); void readFolder(string filename, int type); + void setLang(const char* hello); }; +void Reading::setLang(const char* hello) +{ + lang = hello; + hasLang = true; +} void Reading::readFile(string fname, int type) { std::ifstream file(fname.c_str());