diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 7337529..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "files.associations": { - "xstring": "cpp" - } -} \ No newline at end of file diff --git a/ArgumentQueue.cpp b/ArgumentQueue.cpp new file mode 100644 index 0000000..7195e39 --- /dev/null +++ b/ArgumentQueue.cpp @@ -0,0 +1,173 @@ +#pragma once +#include +#include +#include +#include +#include "ArgumentQueue.h" + + + + +bool SDDS::ArgumentQueue::addArg(const char *switchStr, const char *arg) +{ + bool rc; + Argument *tmpArg = new Argument(); + rc = tmpArg->parseArg(switchStr, arg); + mArgs[mArgCnt++] = tmpArg; + return rc; +} +bool SDDS::ArgumentQueue::execute() +{ + bool rc = false; + bool showVersion = false, showHelp = false, emptyArg = false, unkownArg = false, hasConfig = false; + std::string unkownSwitchStr; + std::string emptySwtichStr; + std::string inputFile; + std::string outputFileDir; + std::string styleSheet; + std::string language; + std::string config; + if (mArgCnt == 0) + { + mMessage = "Please at least specify an input file."; + } + else + { + for (size_t i = 0; i < mArgCnt; i++) + { + switch (mArgs[i]->getArgTag()) + { + case Argument::ArgTag::INPUT: + inputFile = mArgs[i]->mArg; + break; + case Argument::ArgTag::OUTPUT: + outputFileDir = mArgs[i]->mArg; + break; + case Argument::ArgTag::VERSION: + showVersion = !showVersion; + break; + case Argument::ArgTag::EMPTY: + emptyArg = !emptyArg; + emptySwtichStr = mArgs[i]->mSwitchStr; + break; + case Argument::ArgTag::UNKOWN: + unkownArg = !unkownArg; + unkownSwitchStr = mArgs[i]->mSwitchStr; + break; + case Argument::ArgTag::HELP: + showHelp = true; + break; + case Argument::ArgTag::CSS: + styleSheet = mArgs[i]->mArg; + break; + case Argument::ArgTag::LANGUAGE: + language = mArgs[i]->mArg; + break; + case Argument::ArgTag::CONFIG: + config = mArgs[i]->mArg; + hasConfig = true; + break; + } + } + if (hasConfig) + try { + fileProcessor.parseJSONConfig(config, inputFile, outputFileDir, styleSheet, language); + } + catch (const std::exception ex) { + throw std::exception(); + } + if (unkownArg) + { + messagePrinter.printUnknownSwitch(unkownSwitchStr); + throw std::exception(); + } + else if (showHelp) + messagePrinter.printHelp(); + else if (showVersion) + messagePrinter.printVersion(); + else if (emptyArg) + { + messagePrinter.printEmptyArg(emptySwtichStr); + throw std::exception(); + } + else if (inputFile.empty()) + messagePrinter.printInputFileNotProvided(); + else + fileProcessor.processFile(inputFile, outputFileDir, styleSheet, language); + } + return rc; +} +SDDS::ArgumentQueue::ArgumentQueue() { + fileProcessor = FileProcessor(); + messagePrinter = MessagePrinter(); +} +SDDS::ArgumentQueue::~ArgumentQueue() +{ +} +bool SDDS::Argument::parseArg(const char *switchStr, const char *arg) +{ + if (mArg != nullptr) + delete mArg; + if (arg != nullptr) + { + mArg = new char[std::strlen(arg)]; + std::strcpy(mArg, arg); + } + mSwitchStr = new char[std::strlen(switchStr)]; + strcpy(mSwitchStr, switchStr); + + if (std::strcmp(switchStr, "--help") == 0 || std::strcmp(switchStr, "-h") == 0) + { + mArgTag = ArgTag::HELP; + } + else if (std::strcmp(switchStr, "--input") == 0 || std::strcmp(switchStr, "-i") == 0) + { + mArgTag = ArgTag::INPUT; + } + else if (std::strcmp(switchStr, "--output") == 0 || std::strcmp(switchStr, "-o") == 0) + { + mArgTag = ArgTag::OUTPUT; + } + else if (std::strcmp(switchStr, "--version") == 0 || std::strcmp(switchStr, "-v") == 0) + { + mArgTag = ArgTag::VERSION; + } + else if (std::strcmp(switchStr, "--stylesheet") == 0 || std::strcmp(switchStr, "-s") == 0) + mArgTag = ArgTag::CSS; + else if (std::strcmp(switchStr, "--lang") == 0 || std::strcmp(switchStr, "-l") == 0 || std::strcmp(switchStr, "/l") == 0 || std::strcmp(switchStr, "\\l") == 0) + mArgTag = ArgTag::LANGUAGE; + else if (std::strcmp(switchStr, "--config") == 0 || std::strcmp(switchStr, "-c") == 0) + { + mArgTag = ArgTag::CONFIG; + } + else + { + mArgTag = ArgTag::UNKOWN; + return false; + } + // check if argument is necessary for the current switch + if (mArgTag != ArgTag::VERSION && mArgTag != ArgTag::HELP && mArgTag != ArgTag::UNKOWN) + { + if (arg == nullptr) + { + mArgTag = ArgTag::EMPTY; + return false; + } + } + return true; +} + +SDDS::Argument::ArgTag SDDS::Argument::getArgTag() +{ + return mArgTag; +} +SDDS::Argument::~Argument() +{ + // if (mArg != nullptr) + // delete[] mArg; +} + + + +// Markdown version of Convert File + diff --git a/Project1/ArgumentQueue.h b/ArgumentQueue.h similarity index 70% rename from Project1/ArgumentQueue.h rename to ArgumentQueue.h index 228c967..cb1cf1d 100644 --- a/Project1/ArgumentQueue.h +++ b/ArgumentQueue.h @@ -1,43 +1,46 @@ -#pragma once -namespace SDDS -{ - - class Argument - { - public: - friend class ArgumentQueue; - enum class ArgTag - { - VERSION, - INPUT, - OUTPUT, - HELP, - UNKOWN, - ERROR, - EMPTY, - CSS, - LANGUAGE, - CONFIG - }; - ArgTag getArgTag(); - bool parseArg(const char *switchStr, const char *arg); - ~Argument(); - - private: - SDDS::Argument::ArgTag mArgTag = SDDS::Argument::ArgTag::UNKOWN; - char *mArg = nullptr; - char *mSwitchStr = nullptr; - }; - class ArgumentQueue - { - Argument **mArgs = new Argument *[0]; - size_t mArgCnt = 0; - std::string mMessage; - void convertFile(std::string inputFile, std::string outputFileDir, std::string stylesheet, std::string language); - void convertFileMD(std::string inputFile, std::string outputFileDir, std::string stylesheet, std::string language); - public: - bool addArg(const char *switchStr, const char *arg); - bool execute(); - ~ArgumentQueue(); - }; -} +#pragma once +#include "MessagePrinter.h" +#include "FileProcessor.h" +namespace SDDS +{ + + class Argument + { + public: + friend class ArgumentQueue; + enum class ArgTag + { + VERSION, + INPUT, + OUTPUT, + HELP, + UNKOWN, + ERROR, + EMPTY, + CSS, + LANGUAGE, + CONFIG + }; + ArgTag getArgTag(); + bool parseArg(const char *switchStr, const char *arg); + ~Argument(); + + private: + SDDS::Argument::ArgTag mArgTag = SDDS::Argument::ArgTag::UNKOWN; + char *mArg = nullptr; + char *mSwitchStr = nullptr; + }; + class ArgumentQueue + { + Argument **mArgs = new Argument *[0]; + size_t mArgCnt = 0; + std::string mMessage; + FileProcessor fileProcessor; + MessagePrinter messagePrinter; + public: + bool addArg(const char *switchStr, const char *arg); + bool execute(); + ArgumentQueue(); + ~ArgumentQueue(); + }; +} diff --git a/FileProcessor.cpp b/FileProcessor.cpp new file mode 100644 index 0000000..a320e0a --- /dev/null +++ b/FileProcessor.cpp @@ -0,0 +1,126 @@ +#include "FileProcessor.h" +#include "Utils.h" + +void SDDS::FileProcessor::convertFile(std::string inputFile, std::string outputFileDir, std::string stylesheet, std::string language) +{ + std::string fileContent = SDDS::readFileAsHtmlStr(inputFile).c_str(); + std::filesystem::create_directory(outputFileDir); + if (fileContent.empty()) + { + std::cout << "Cannot find file or directory: " << inputFile << std::endl; + throw std::exception(); + } + else + { + std::string fileName = SDDS::extractFileName(inputFile); + fileName = fileName.substr(0, fileName.find('.')); + const std::string HTMLContentStr = SDDS::generateHTMLAsStr(fileName, fileContent, stylesheet, language); + if (outputFileDir.substr(0, 2) == "./" || outputFileDir.substr(0, 2) == ".\\") // remove the ./ or .\ at the begining of the output file directory. + outputFileDir = outputFileDir.substr(outputFileDir.find(".") + 1, outputFileDir.length()); + if (outputFileDir.find("\\") == std::string::npos && outputFileDir.find("/") == std::string::npos) // Append the output path with "/" if the output arg is not postfixed with / + outputFileDir.append("/"); + std::string filePath = "./" + outputFileDir + fileName + ".html"; + if (SDDS::writeHTMLToFile(filePath, HTMLContentStr)) + std::cout << filePath << " is successfully converted and written." << std::endl; + else + { + std::cout << "Could not write " << filePath << std::endl; + throw std::exception(); + } + } +} + +void SDDS::FileProcessor::processFile(std::string inputFile, std::string outputFileDir, std::string styleSheet, std::string language) +{ + if (outputFileDir.empty()) + { + std::cout << "Default directory \"dist\" will be used as the output directory." << std::endl; + outputFileDir = "dist/"; + } + if (std::filesystem::exists(outputFileDir)) + { // Clear the output directory first. + std::filesystem::remove_all(outputFileDir); + } + + if (SDDS::checkIfItsDirectory(inputFile)) + { // if the input arg is a directory + for (const auto &entry : std::filesystem::directory_iterator(inputFile)) + { + chooseFileType(entry.path().string(), outputFileDir, styleSheet, language); + } + } + // added checks for if it is a text file or markdown file + else + { + chooseFileType(inputFile, outputFileDir, styleSheet, language); + } +} + +void SDDS::FileProcessor::parseJSONConfig(std::string configPath, std::string &inputFile, std::string &outputFileDir, std::string &styleSheet, std::string &language) +{ + try + { + json data = SDDS::readJSONContents(configPath); + + // goes through the JSON object and fills the options with the correct input + for (json::iterator it = data.begin(); it != data.end(); ++it) + { + if (it.key() == "input") + { + inputFile = *it; + } + else if (it.key() == "output") + { + outputFileDir = *it; + } + else if (it.key() == "stylesheet") + { + styleSheet = *it; + } + else if (it.key() == "lang") + { + language = *it; + } + } + } + catch (const std::exception &e) + { + std::cout << "Cannot find config file: " << configPath << std::endl; + throw std::exception(); + } +} + +void SDDS::FileProcessor::convertFileMD(std::string inputFile, std::string outputFileDir, std::string stylesheet, std::string language) +{ + std::string fileContent = SDDS::readFileAsHtmlStrMD(inputFile).c_str(); + std::filesystem::create_directory(outputFileDir); + if (fileContent.empty()) + { + std::cout << "Cannot find file or directory: " << inputFile << std::endl; + } + else + { + std::string fileName = SDDS::extractFileName(inputFile); + fileName = fileName.substr(0, fileName.find('.')); + const std::string HTMLContentStr = SDDS::generateHTMLAsStr(fileName, fileContent, stylesheet, language); + if (outputFileDir.substr(0, 2) == "./" || outputFileDir.substr(0, 2) == ".\\") // remove the ./ or .\ at the begining of output file directory. + outputFileDir = outputFileDir.substr(outputFileDir.find(".") + 1, outputFileDir.length()); + if (outputFileDir.find("\\") == std::string::npos && outputFileDir.find("/") == std::string::npos) // Append output path with "/" if the output arg is not postfixed with / + outputFileDir.append("/"); + std::string filePath = "./" + outputFileDir + fileName + ".html"; + if (SDDS::writeHTMLToFile(filePath, HTMLContentStr)) + std::cout << filePath << " is successfully converted and written." << std::endl; + else + std::cout << "Could not write " << filePath << std::endl; + } +} + +void SDDS::FileProcessor::chooseFileType(std::string inputFile, std::string outputFileDir, std::string styleSheet, std::string language) +{ + if (inputFile.find(".txt") != std::string::npos) // checks if it is txt file + convertFile(inputFile, outputFileDir, styleSheet, language); + else if (inputFile.find(".md") != std::string::npos) // checks if it is md file + convertFileMD(inputFile, outputFileDir, styleSheet, language); + else + std::cout << "Cannot Find File or Directory" << std::endl; +} diff --git a/FileProcessor.h b/FileProcessor.h new file mode 100644 index 0000000..9476df7 --- /dev/null +++ b/FileProcessor.h @@ -0,0 +1,18 @@ +#pragma once +#include +#include +#include "json.hpp" +namespace SDDS +{ + using json = nlohmann::json; + class FileProcessor + { + public: + void convertFile(std::string inputFile, std::string outputFileDir, std::string stylesheet, std::string language); + void processFile(std::string inputFile, std::string outputFileDir, std::string styleSheet, std::string language); + void parseJSONConfig(std::string, std::string &inputFile, std::string &outputFileDir, std::string &styleSheet, std::string &language); + // Convert MarkDown file to HTML + void convertFileMD(std::string inputFile, std::string outputFileDir, std::string stylesheet, std::string language); + void chooseFileType(std::string inputFile, std::string outputFileDir, std::string styleSheet, std::string language); + }; +} diff --git a/MessagePrinter.cpp b/MessagePrinter.cpp new file mode 100644 index 0000000..77c700b --- /dev/null +++ b/MessagePrinter.cpp @@ -0,0 +1,41 @@ +#include +#include "MessagePrinter.h" + +void SDDS::MessagePrinter::printHelp() +{ + std::cout + << "Usage: ssgifier --input [optional command]" << std::endl + << std::endl + << "SSGifier is a commandline application to generate static website from txt or md files." << std::endl + << std::endl + << "The list below is all the different parameters you can pass to SSGifier." << std::endl + << "-o, --output - (Optional) specify the output directory, the directory \" dlist\" is used by default." << std::endl + << "-i, --input - (Necessary) specify the input files\\directory, this is an necessary argument." << std::endl + << "-s, --stylesheet - (Optional) specify the stylesheet for the HTML pages." << std::endl + << "-l, --lang, /l, \\l - (Optional) specify the language that the HTML uses, it will be added to lang attirbute of ." << std::endl + << "-h, --help - show help." << std::endl + << "-v, --version - prints out the version of SSGifier" << std::endl; +} + +void SDDS::MessagePrinter::printUnknownSwitch(std::string switchName) +{ + std::cout << "Unkown switch " + << "\"" << switchName << "\"." << std::endl + << "Use --help or -h for help." << std::endl; + throw std::exception(); +} + +void SDDS::MessagePrinter::printVersion() +{ + std::cout << "SSGifier " << SDDS::VERSION_NAME << " by Tong Liu" << std::endl; +} + +void SDDS::MessagePrinter::printInputFileNotProvided() +{ + std::cout << "Input file is necessary to be provided." << std::endl; +} + +void SDDS::MessagePrinter::printEmptyArg(std::string switchName) +{ + std::cout << "Empty argument for " << '"' << switchName << '"' << " is provided." << std::endl; +} diff --git a/MessagePrinter.h b/MessagePrinter.h new file mode 100644 index 0000000..291bed8 --- /dev/null +++ b/MessagePrinter.h @@ -0,0 +1,27 @@ +#pragma once +namespace SDDS +{ + static std::string VERSION_NAME = ""; + static int VERSION_CODE = 1; + class MessagePrinter + { + public: + void printHelp(); + /** + * Print unkown switch error meessage. + */ + void printUnknownSwitch(std::string switchName); + /** + * Print current software's version. + */ + void printVersion(); + /** + * Print intput file not found error message. + */ + void printInputFileNotProvided(); + /** + * Print empty argument error message. + */ + void printEmptyArg(std::string switchName); + }; +} diff --git a/Project1/.vs/Project1/v16/.suo b/Project1/.vs/Project1/v16/.suo deleted file mode 100644 index 561f317..0000000 Binary files a/Project1/.vs/Project1/v16/.suo and /dev/null differ diff --git a/Project1/.vs/Project1/v16/Browse.VC.db b/Project1/.vs/Project1/v16/Browse.VC.db deleted file mode 100644 index 24f4548..0000000 Binary files a/Project1/.vs/Project1/v16/Browse.VC.db and /dev/null differ diff --git a/Project1/.vs/Project1/v16/ipch/AutoPCH/59b0aab40f545a27/XTHROW.ipch b/Project1/.vs/Project1/v16/ipch/AutoPCH/59b0aab40f545a27/XTHROW.ipch deleted file mode 100644 index 8804305..0000000 Binary files a/Project1/.vs/Project1/v16/ipch/AutoPCH/59b0aab40f545a27/XTHROW.ipch and /dev/null differ diff --git a/Project1/.vs/Project1/v16/ipch/AutoPCH/a68bd5e830579135/MAIN.ipch b/Project1/.vs/Project1/v16/ipch/AutoPCH/a68bd5e830579135/MAIN.ipch deleted file mode 100644 index 788a7b4..0000000 Binary files a/Project1/.vs/Project1/v16/ipch/AutoPCH/a68bd5e830579135/MAIN.ipch and /dev/null differ diff --git a/Project1/.vs/Project1/v16/ipch/AutoPCH/eb10b0e9769d23e8/ARGUMENTQUEUE.ipch b/Project1/.vs/Project1/v16/ipch/AutoPCH/eb10b0e9769d23e8/ARGUMENTQUEUE.ipch deleted file mode 100644 index f2bdfa2..0000000 Binary files a/Project1/.vs/Project1/v16/ipch/AutoPCH/eb10b0e9769d23e8/ARGUMENTQUEUE.ipch and /dev/null differ diff --git a/Project1/ArgumentQueue.cpp b/Project1/ArgumentQueue.cpp deleted file mode 100644 index 7a850b3..0000000 --- a/Project1/ArgumentQueue.cpp +++ /dev/null @@ -1,304 +0,0 @@ -#include -#include -#include -#include -#include "ArgumentQueue.h" -#include "Utils.h" -#include "json.hpp" - -using json = nlohmann::json; - -bool SDDS::ArgumentQueue::addArg(const char *switchStr, const char *arg) -{ - bool rc; - Argument *tmpArg = new Argument(); - rc = tmpArg->parseArg(switchStr, arg); - mArgs[mArgCnt++] = tmpArg; - return rc; -} -bool SDDS::ArgumentQueue::execute() -{ - bool rc = false; - bool showVersion = false, showHelp = false, emptyArg = false, unkownArg = false, hasConfig = false; - std::string unkownSwitchStr; - std::string emptySwtichStr; - std::string inputFile; - std::string outputFileDir; - std::string styleSheet; - std::string language; - std::string config; - if (mArgCnt == 0) - { - mMessage = "Please at least specify an input file."; - } - else - { - for (size_t i = 0; i < mArgCnt; i++) - { - switch (mArgs[i]->getArgTag()) - { - case Argument::ArgTag::INPUT: - inputFile = mArgs[i]->mArg; - break; - case Argument::ArgTag::OUTPUT: - outputFileDir = mArgs[i]->mArg; - break; - case Argument::ArgTag::VERSION: - showVersion = !showVersion; - break; - case Argument::ArgTag::EMPTY: - emptyArg = !emptyArg; - emptySwtichStr = mArgs[i]->mSwitchStr; - break; - case Argument::ArgTag::UNKOWN: - unkownArg = !unkownArg; - unkownSwitchStr = mArgs[i]->mSwitchStr; - break; - case Argument::ArgTag::HELP: - showHelp = true; - break; - case Argument::ArgTag::CSS: - styleSheet = mArgs[i]->mArg; - break; - case Argument::ArgTag::LANGUAGE: - language = mArgs[i]->mArg; - break; - case Argument::ArgTag::CONFIG: - config = mArgs[i]->mArg; - hasConfig = true; - break; - } - } - if (hasConfig) - { - try - { - json data = SDDS::readJSONContents(config); - - // goes through the JSON object and fills the options with the correct input - for (json::iterator it = data.begin(); it != data.end(); ++it) { - if (it.key() == "input") - { - inputFile = *it; - } - else if(it.key() == "output") - { - outputFileDir = *it; - } - else if(it.key() == "stylesheet") - { - styleSheet = *it; - } - else if(it.key() == "lang") - { - language = *it; - } - - } - } - catch(const std::exception& e) - { - std::cout << "Cannot find config file: " << config << std::endl; - throw std::exception(); - } - } - if (unkownArg) - { - std::cout << "Unkown switch " - << "\"" << unkownSwitchStr << "\"." << std::endl - << "Use --help or -h for help." << std::endl; - throw std::exception(); - } - else if (showHelp) - std::cout - << "Usage: ssgifier --input [optional command]" << std::endl - << std::endl - << "SSGifier is a commandline application to generate static website from txt or md files." << std::endl - << std::endl - << "The list below is all the different parameters you can pass to SSGifier." << std::endl - << "-o, --output - (Optional) specify the output directory, the directory \" dlist\" is used by default." << std::endl - << "-i, --input - (Necessary) specify the input files\\directory, this is an necessary argument." << std::endl - << "-s, --stylesheet - (Optional) specify the stylesheet for the HTML pages." << std::endl - << "-l, --lang, /l, \\l - (Optional) specify the language that the HTML uses, it will be added to lang attirbute of ." << std::endl - << "-h, --help - show help." << std::endl - << "-v, --version - prints out the version of SSGifier" << std::endl; - else if (showVersion) - std::cout << "SSGifier V0.1 by Tong Liu" << std::endl; - else if (emptyArg) - { - std::cout << "Empty argument for " << '"' << emptySwtichStr << '"' << " is provided." << std::endl; - throw std::exception(); - } - else if (inputFile.empty()) - std::cout << "Input file is necessary to be provided." << std::endl; - else - { - if (outputFileDir.empty()) - { - std::cout << "Default directory \"dist\" will be used as the output directory." << std::endl; - outputFileDir = "dist/"; - } - if (std::filesystem::exists(outputFileDir)) - { // Clear the output directory first. - std::filesystem::remove_all(outputFileDir); - } - - //removes ./ if input has it inside of the command - if (inputFile.at(0) == '.' && inputFile.at(1) == '/') - { - inputFile = inputFile.substr(2); - } - //removes ./ if outPutDir has it inside of the command - if (outputFileDir.at(0) == '.' && outputFileDir.at(1) == '/') - { - outputFileDir = outputFileDir.substr(2); - } - - if (SDDS::checkIfItsDirectory(inputFile)) - { // if the input arg is a directory - for (const auto &entry : std::filesystem::directory_iterator(inputFile)) - { - if (entry.path().string().find(".txt") != std::string::npos) // process .txt files - convertFile(entry.path().string(), outputFileDir, styleSheet, language); - else if (entry.path().string().find(".md") != std::string::npos) // process .md files - convertFileMD(entry.path().string(), outputFileDir, styleSheet, language); - } - } - // added checks for if it is a text file or markdown file - else if (inputFile.find(".txt") != std::string::npos) // checks if it is txt file - { - convertFile(inputFile, outputFileDir, styleSheet, language); - } - else if (inputFile.find(".md") != std::string::npos) // checks if it is md file - { - convertFileMD(inputFile, outputFileDir, styleSheet, language); - } - else - { - std::cout << "Cannot Find File or Directory" << std::endl; - } - } - } - return rc; -} -SDDS::ArgumentQueue::~ArgumentQueue() -{ -} -bool SDDS::Argument::parseArg(const char *switchStr, const char *arg) -{ - if (mArg != nullptr) - delete mArg; - if (arg != nullptr) - { - mArg = new char[std::strlen(arg)]; - std::strcpy(mArg, arg); - } - mSwitchStr = new char[std::strlen(switchStr)]; - strcpy(mSwitchStr, switchStr); - - if (std::strcmp(switchStr, "--help") == 0 || std::strcmp(switchStr, "-h") == 0) - { - mArgTag = ArgTag::HELP; - } - else if (std::strcmp(switchStr, "--input") == 0 || std::strcmp(switchStr, "-i") == 0) - { - mArgTag = ArgTag::INPUT; - } - else if (std::strcmp(switchStr, "--output") == 0 || std::strcmp(switchStr, "-o") == 0) - { - mArgTag = ArgTag::OUTPUT; - } - else if (std::strcmp(switchStr, "--version") == 0 || std::strcmp(switchStr, "-v") == 0) - { - mArgTag = ArgTag::VERSION; - } - else if (std::strcmp(switchStr, "--stylesheet") == 0 || std::strcmp(switchStr, "-s") == 0) - mArgTag = ArgTag::CSS; - else if (std::strcmp(switchStr, "--lang") == 0 || std::strcmp(switchStr, "-l") == 0 || std::strcmp(switchStr, "/l") == 0 || std::strcmp(switchStr, "\\l") == 0) - mArgTag = ArgTag::LANGUAGE; - else if (std::strcmp(switchStr, "--config") == 0 || std::strcmp(switchStr, "-c") == 0) - { - mArgTag = ArgTag::CONFIG; - } - else - { - mArgTag = ArgTag::UNKOWN; - return false; - } - // check if argument is necessary for the current switch - if (mArgTag != ArgTag::VERSION && mArgTag != ArgTag::HELP && mArgTag != ArgTag::UNKOWN) - { - if (arg == nullptr) - { - mArgTag = ArgTag::EMPTY; - return false; - } - } - return true; -} - -SDDS::Argument::ArgTag SDDS::Argument::getArgTag() -{ - return mArgTag; -} -SDDS::Argument::~Argument() -{ - // if (mArg != nullptr) - // delete[] mArg; -} - -void SDDS::ArgumentQueue::convertFile(std::string inputFile, std::string outputFileDir, std::string stylesheet, std::string language) -{ - - std::string fileContent = SDDS::readFileAsHtmlStr(inputFile).c_str(); - std::filesystem::create_directory(outputFileDir); - if (fileContent.empty()) - { - std::cout << "Cannot find file or directory: " << inputFile << std::endl; - throw std::exception(); - } - else - { - std::string fileName = SDDS::extractFileName(inputFile); - fileName = fileName.substr(0, fileName.find('.')); - const std::string HTMLContentStr = SDDS::generateHTMLAsStr(fileName, fileContent, stylesheet, language); - if (outputFileDir.substr(0, 2) == "./" || outputFileDir.substr(0, 2) == ".\\") // remove the ./ or .\ at the begining of output file directory. - outputFileDir = outputFileDir.substr(outputFileDir.find(".") + 1, outputFileDir.length()); - if (outputFileDir.find("\\") == std::string::npos && outputFileDir.find("/") == std::string::npos) // Append output path with "/" if the output arg is not postfixed with / - outputFileDir.append("/"); - std::string filePath = "./" + outputFileDir + fileName + ".html"; - if (SDDS::writeHTMLToFile(filePath, HTMLContentStr)) - std::cout << filePath << " is successfully converted and written." << std::endl; - else - { - std::cout << "Could not write " << filePath << std::endl; - throw std::exception(); - } - } -} - -// Markdown version of Convert File -void SDDS::ArgumentQueue::convertFileMD(std::string inputFile, std::string outputFileDir, std::string stylesheet, std::string language) -{ - std::string fileContent = SDDS::readFileAsHtmlStrMD(inputFile).c_str(); - std::filesystem::create_directory(outputFileDir); - if (fileContent.empty()) - { - std::cout << "Cannot find file or directory: " << inputFile << std::endl; - } - else - { - std::string fileName = SDDS::extractFileName(inputFile); - fileName = fileName.substr(0, fileName.find('.')); - const std::string HTMLContentStr = SDDS::generateHTMLAsStr(fileName, fileContent, stylesheet, language); - if (outputFileDir.substr(0, 2) == "./" || outputFileDir.substr(0, 2) == ".\\") // remove the ./ or .\ at the begining of output file directory. - outputFileDir = outputFileDir.substr(outputFileDir.find(".") + 1, outputFileDir.length()); - if (outputFileDir.find("\\") == std::string::npos && outputFileDir.find("/") == std::string::npos) // Append output path with "/" if the output arg is not postfixed with / - outputFileDir.append("/"); - std::string filePath = "./" + outputFileDir + fileName + ".html"; - if (SDDS::writeHTMLToFile(filePath, HTMLContentStr)) - std::cout << filePath << " is successfully converted and written." << std::endl; - else - std::cout << "Could not write " << filePath << std::endl; - } -} diff --git a/Project1/Debug/ArgumentQueue.obj b/Project1/Debug/ArgumentQueue.obj deleted file mode 100644 index 9e9bae8..0000000 Binary files a/Project1/Debug/ArgumentQueue.obj and /dev/null differ diff --git a/Project1/Debug/Project1.Build.CppClean.log b/Project1/Debug/Project1.Build.CppClean.log deleted file mode 100644 index 2c795dd..0000000 --- a/Project1/Debug/Project1.Build.CppClean.log +++ /dev/null @@ -1,13 +0,0 @@ -c:\users\piotr\desktop\ssgifier\project1\debug\vc142.pdb -c:\users\piotr\desktop\ssgifier\project1\debug\vc142.idb -c:\users\piotr\desktop\ssgifier\project1\debug\main.obj -c:\users\piotr\desktop\ssgifier\project1\debug\argumentqueue.obj -c:\users\piotr\desktop\ssgifier\project1\debug\project1.exe -c:\users\piotr\desktop\ssgifier\project1\debug\project1.ilk -c:\users\piotr\desktop\ssgifier\project1\debug\project1.pdb -c:\users\piotr\desktop\ssgifier\project1\debug\project1.tlog\cl.command.1.tlog -c:\users\piotr\desktop\ssgifier\project1\debug\project1.tlog\cl.read.1.tlog -c:\users\piotr\desktop\ssgifier\project1\debug\project1.tlog\cl.write.1.tlog -c:\users\piotr\desktop\ssgifier\project1\debug\project1.tlog\link.command.1.tlog -c:\users\piotr\desktop\ssgifier\project1\debug\project1.tlog\link.read.1.tlog -c:\users\piotr\desktop\ssgifier\project1\debug\project1.tlog\link.write.1.tlog diff --git a/Project1/Debug/Project1.exe b/Project1/Debug/Project1.exe deleted file mode 100644 index 2bba25b..0000000 Binary files a/Project1/Debug/Project1.exe and /dev/null differ diff --git a/Project1/Debug/Project1.exe.recipe b/Project1/Debug/Project1.exe.recipe deleted file mode 100644 index 67e575b..0000000 --- a/Project1/Debug/Project1.exe.recipe +++ /dev/null @@ -1,11 +0,0 @@ - - - - - C:\Users\piotr\Desktop\SSGifier\Project1\Debug\Project1.exe - - - - - - \ No newline at end of file diff --git a/Project1/Debug/Project1.ilk b/Project1/Debug/Project1.ilk deleted file mode 100644 index a8ebb07..0000000 Binary files a/Project1/Debug/Project1.ilk and /dev/null differ diff --git a/Project1/Debug/Project1.log b/Project1/Debug/Project1.log deleted file mode 100644 index f9007de..0000000 --- a/Project1/Debug/Project1.log +++ /dev/null @@ -1,4 +0,0 @@ - ArgumentQueue.cpp -C:\Users\piotr\Desktop\SSGifier\Project1\ArgumentQueue.cpp(131,8): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. -C:\Users\piotr\Desktop\SSGifier\Project1\ArgumentQueue.cpp(134,2): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. - Project1.vcxproj -> C:\Users\piotr\Desktop\SSGifier\Project1\Debug\Project1.exe diff --git a/Project1/Debug/Project1.pdb b/Project1/Debug/Project1.pdb deleted file mode 100644 index ddbc48f..0000000 Binary files a/Project1/Debug/Project1.pdb and /dev/null differ diff --git a/Project1/Debug/Project1.tlog/CL.command.1.tlog b/Project1/Debug/Project1.tlog/CL.command.1.tlog deleted file mode 100644 index 6e27b16..0000000 Binary files a/Project1/Debug/Project1.tlog/CL.command.1.tlog and /dev/null differ diff --git a/Project1/Debug/Project1.tlog/CL.read.1.tlog b/Project1/Debug/Project1.tlog/CL.read.1.tlog deleted file mode 100644 index 057301a..0000000 Binary files a/Project1/Debug/Project1.tlog/CL.read.1.tlog and /dev/null differ diff --git a/Project1/Debug/Project1.tlog/CL.write.1.tlog b/Project1/Debug/Project1.tlog/CL.write.1.tlog deleted file mode 100644 index c6f8315..0000000 Binary files a/Project1/Debug/Project1.tlog/CL.write.1.tlog and /dev/null differ diff --git a/Project1/Debug/Project1.tlog/Project1.lastbuildstate b/Project1/Debug/Project1.tlog/Project1.lastbuildstate deleted file mode 100644 index 056859b..0000000 --- a/Project1/Debug/Project1.tlog/Project1.lastbuildstate +++ /dev/null @@ -1,2 +0,0 @@ -PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.28.29910:TargetPlatformVersion=10.0.18362.0: -Debug|Win32|C:\Users\piotr\Desktop\SSGifier\Project1\| diff --git a/Project1/Debug/Project1.tlog/link.command.1.tlog b/Project1/Debug/Project1.tlog/link.command.1.tlog deleted file mode 100644 index 5c3a609..0000000 Binary files a/Project1/Debug/Project1.tlog/link.command.1.tlog and /dev/null differ diff --git a/Project1/Debug/Project1.tlog/link.read.1.tlog b/Project1/Debug/Project1.tlog/link.read.1.tlog deleted file mode 100644 index 0b7783d..0000000 Binary files a/Project1/Debug/Project1.tlog/link.read.1.tlog and /dev/null differ diff --git a/Project1/Debug/Project1.tlog/link.write.1.tlog b/Project1/Debug/Project1.tlog/link.write.1.tlog deleted file mode 100644 index efafb17..0000000 Binary files a/Project1/Debug/Project1.tlog/link.write.1.tlog and /dev/null differ diff --git a/Project1/Debug/Project1.vcxproj.FileListAbsolute.txt b/Project1/Debug/Project1.vcxproj.FileListAbsolute.txt deleted file mode 100644 index 6d9ad37..0000000 --- a/Project1/Debug/Project1.vcxproj.FileListAbsolute.txt +++ /dev/null @@ -1 +0,0 @@ -C:\Users\piotr\Desktop\SSGifier\Project1\Debug\Project1.exe diff --git a/Project1/Debug/main.obj b/Project1/Debug/main.obj deleted file mode 100644 index 1f2da10..0000000 Binary files a/Project1/Debug/main.obj and /dev/null differ diff --git a/Project1/Debug/vc142.idb b/Project1/Debug/vc142.idb deleted file mode 100644 index cc4bc1d..0000000 Binary files a/Project1/Debug/vc142.idb and /dev/null differ diff --git a/Project1/Debug/vc142.pdb b/Project1/Debug/vc142.pdb deleted file mode 100644 index a2b06c7..0000000 Binary files a/Project1/Debug/vc142.pdb and /dev/null differ diff --git a/Project1/Project1.sln b/Project1/Project1.sln deleted file mode 100644 index ba8da1b..0000000 --- a/Project1/Project1.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31205.134 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project1", "Project1.vcxproj", "{DFC27454-AFF2-442C-904E-2A28B9F9AA3F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DFC27454-AFF2-442C-904E-2A28B9F9AA3F}.Debug|x64.ActiveCfg = Debug|x64 - {DFC27454-AFF2-442C-904E-2A28B9F9AA3F}.Debug|x64.Build.0 = Debug|x64 - {DFC27454-AFF2-442C-904E-2A28B9F9AA3F}.Debug|x86.ActiveCfg = Debug|Win32 - {DFC27454-AFF2-442C-904E-2A28B9F9AA3F}.Debug|x86.Build.0 = Debug|Win32 - {DFC27454-AFF2-442C-904E-2A28B9F9AA3F}.Release|x64.ActiveCfg = Release|x64 - {DFC27454-AFF2-442C-904E-2A28B9F9AA3F}.Release|x64.Build.0 = Release|x64 - {DFC27454-AFF2-442C-904E-2A28B9F9AA3F}.Release|x86.ActiveCfg = Release|Win32 - {DFC27454-AFF2-442C-904E-2A28B9F9AA3F}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {4AA7593C-53F9-41B3-837F-D45F523110D4} - EndGlobalSection -EndGlobal diff --git a/Project1/Project1.vcxproj b/Project1/Project1.vcxproj deleted file mode 100644 index 97a8246..0000000 --- a/Project1/Project1.vcxproj +++ /dev/null @@ -1,156 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {dfc27454-aff2-442c-904e-2a28b9f9aa3f} - Project1 - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - false - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Project1/Project1.vcxproj.filters b/Project1/Project1.vcxproj.filters deleted file mode 100644 index bb4d8a4..0000000 --- a/Project1/Project1.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - - - Header Files - - - Source Files - - - - - Source Files - - - \ No newline at end of file diff --git a/Project1/Project1.vcxproj.user b/Project1/Project1.vcxproj.user deleted file mode 100644 index 9ba9168..0000000 --- a/Project1/Project1.vcxproj.user +++ /dev/null @@ -1,7 +0,0 @@ - - - - --input test.md - WindowsLocalDebugger - - \ No newline at end of file diff --git a/Project1/Utils.h b/Utils.h similarity index 79% rename from Project1/Utils.h rename to Utils.h index f29af32..741ce5b 100644 --- a/Project1/Utils.h +++ b/Utils.h @@ -1,161 +1,163 @@ -#pragma once -#include -#include -#include -#include -#include -#include "json.hpp" - -using json = nlohmann::json; - -namespace SDDS -{ - const std::string generateHTMLAsStr(const std::string fileName, const std::string content, const std::string stylesheet, const std::string language) - { - std::stringstream ss; - ss << "\n" - << "" << std::endl - << "" << std::endl; - if (!stylesheet.empty()) - ss << "" << std::endl - << "" << fileName << "" << std::endl - << "" << std::endl - << "" << std::endl - << "" << std::endl - << "

" << fileName << "

" << std::endl - << "
" << std::endl - << "
" << std::endl - << content << "\n"; - - return ss.str(); - } - /** - * - * - **/ - const std::string readFileAsHtmlStr(const std::string filePath) - { - std::ifstream input(filePath); - std::string inputStr; - if (input.good()) - { - std::getline(input, inputStr); - inputStr.append("\n").append("
\n").append("
\n"); - inputStr = "

" + inputStr; - } - while (input.good()) - { - std::string strTmp; - std::getline(input, strTmp); - strTmp = "

" + strTmp; - strTmp.append("

"); - inputStr.append(strTmp); - inputStr.append("\n"); - } - return inputStr.c_str(); - } - // Markdown version of read File - const std::string readFileAsHtmlStrMD(const std::string filePath) // Markdown Conversion - { - std::ifstream input(filePath); - std::string inputStr; - if (input.good()) - { - std::getline(input, inputStr); - inputStr.append("

\n").append("
\n").append("
\n"); - inputStr = "

" + inputStr; - } - while (input.good()) - { - std::string strTmp; - std::getline(input, strTmp); - // Checks for markdown heading tag - if (strTmp.find("# ") != std::string::npos) - { - if (strTmp.at(0) == '#' && strTmp.at(1) == ' ') - { - strTmp.replace(0, 2, ""); - strTmp = "

" + strTmp; - strTmp.append("

"); - } - else - { - strTmp = "

" + strTmp; - strTmp.append("

"); - } - } - else - { - strTmp = "

" + strTmp; - strTmp.append("

"); - } - - // Indents the string by finding the astrix - if (strTmp.find('*') != std::string::npos) - { - // Position of the first astrix - size_t astrix = strTmp.find("*"); - // Position of the last astrix - size_t pos = 0; - - // Loops through the string to look for the astrix - for (size_t i = astrix + 1; i < strTmp.size(); i++) - { - if (strTmp.at(i) == '*') - pos = i; - } - - // Stores the end of the string to add after the indent - std::string endStr = strTmp.substr(pos + 1); - - std::string newStr = "" + strTmp.substr(astrix + 1, (pos - astrix) - 1) + ""; - strTmp.replace(strTmp.find("*"), newStr.size(), newStr); - strTmp.append(endStr); - } - - inputStr.append(strTmp); - inputStr.append("\n"); - } - return inputStr.c_str(); - } - const bool writeHTMLToFile(const std::string filePath, const std::string htmlStr) - { - std::ofstream output(filePath); - if (output.good()) - { - output << htmlStr; - output.close(); - return true; - } - else - return false; - } - const bool checkIfItsDirectory(const std::string path) - { - return std::filesystem::is_directory(path); - } - const std::string extractFileName(std::string filePath) - { - std::string fileName = filePath; - if (filePath.find("/") != std::string::npos) - fileName = filePath.substr(filePath.find_last_of("/") + 1, filePath.length()); - else if (filePath.find("\\") != std::string::npos) - fileName = filePath.substr(filePath.find_last_of("\\") + 1, filePath.length()); - return fileName; - } - const json readJSONContents(std::string config) - { - json data; - try - { - std::ifstream input(config); - data = json::parse(input); - } - catch(const std::exception& e) - { - throw std::exception(); - } - return data; - } -} \ No newline at end of file +#ifndef SDDS_UTILS +#define SDDS_UTILS +#include +#include +#include +#include +#include +#include "json.hpp" + +using json = nlohmann::json; + +namespace SDDS +{ + const std::string generateHTMLAsStr(const std::string fileName, const std::string content, const std::string stylesheet, const std::string language) + { + std::stringstream ss; + ss << "" + << "" + << ""; + if (!stylesheet.empty()) + ss << "" + << "" << fileName << "" + << "" + << "" + << "" + << "

" << fileName << "

" + << "
" + << "
" + << content << ""; + + return ss.str(); + } + /** + * + * + **/ + const std::string readFileAsHtmlStr(const std::string filePath) + { + std::ifstream input(filePath); + std::string inputStr; + if (input.good()) + { + std::getline(input, inputStr); + inputStr.append("").append("
").append("
"); + inputStr = "

" + inputStr; + } + while (input.good()) + { + std::string strTmp; + std::getline(input, strTmp); + strTmp = "

" + strTmp; + strTmp.append("

"); + inputStr.append(strTmp); + } + return inputStr.c_str(); + } + // Markdown version of read File + const std::string readFileAsHtmlStrMD(const std::string filePath) // Markdown Conversion + { + std::ifstream input(filePath); + std::string inputStr; + if (input.good()) + { + std::getline(input, inputStr); + inputStr.append("

").append("
").append("
"); + inputStr = "

" + inputStr; + } + while (input.good()) + { + std::string strTmp; + std::getline(input, strTmp); + // Checks for markdown heading tag + if (strTmp.find("# ") != std::string::npos) + { + if (strTmp.at(0) == '#' && strTmp.at(1) == ' ') + { + strTmp.replace(0, 2, ""); + strTmp = "

" + strTmp; + strTmp.append("

"); + } + else + { + strTmp = "

" + strTmp; + strTmp.append("

"); + } + } + else + { + strTmp = "

" + strTmp; + strTmp.append("

"); + } + + // Indents the string by finding the astrix + if (strTmp.find('*') != std::string::npos) + { + // Position of the first astrix + size_t astrix = strTmp.find("*"); + // Position of the last astrix + size_t pos = 0; + + // Loops through the string to look for the astrix + for (size_t i = astrix + 1; i < strTmp.size(); i++) + { + if (strTmp.at(i) == '*') + pos = i; + } + + // Stores the end of the string to add after the indent + std::string endStr = strTmp.substr(pos + 1); + + std::string newStr = "" + strTmp.substr(astrix + 1, (pos - astrix) - 1) + ""; + strTmp.replace(strTmp.find("*"), newStr.size(), newStr); + strTmp.append(endStr); + } + + inputStr.append(strTmp); + + } + return inputStr.c_str(); + } + const bool writeHTMLToFile(const std::string filePath, const std::string htmlStr) + { + std::ofstream output(filePath); + if (output.good()) + { + output << htmlStr; + output.close(); + return true; + } + else + return false; + } + const bool checkIfItsDirectory(const std::string path) + { + return std::filesystem::is_directory(path); + } + const std::string extractFileName(std::string filePath) + { + std::string fileName = filePath; + if (filePath.find("/") != std::string::npos) + fileName = filePath.substr(filePath.find_last_of("/") + 1, filePath.length()); + else if (filePath.find("\\") != std::string::npos) + fileName = filePath.substr(filePath.find_last_of("\\") + 1, filePath.length()); + return fileName; + } + const json readJSONContents(std::string config) + { + json data; + try + { + std::ifstream input(config); + data = json::parse(input); + } + catch(const std::exception& e) + { + throw std::exception(); + } + return data; + } +} + +#endif // !SDDS_UTIILS \ No newline at end of file diff --git a/Project1/config.json b/config.json similarity index 100% rename from Project1/config.json rename to config.json diff --git a/Project1/json.hpp b/json.hpp similarity index 100% rename from Project1/json.hpp rename to json.hpp diff --git a/Project1/main.cpp b/main.cpp similarity index 94% rename from Project1/main.cpp rename to main.cpp index da53481..394b72b 100644 --- a/Project1/main.cpp +++ b/main.cpp @@ -1,28 +1,28 @@ -#include -#include "ArgumentQueue.h" - -int main(int argc, char *argv[]) -{ - SDDS::ArgumentQueue argQueue; - if (argc <= 1) - { - std::cout << "At least specify an input file. \nPlease run -h or --help for help " << std::endl; - return -1; - } - for (int i = 1; i < argc; i++) - { - if (argv[i][0] == '-' || argv[i][0] == '/' || argv[i][0] == '\\') - { - argQueue.addArg(argv[i], argv[i + 1]); - } - } - try - { - argQueue.execute(); - } - catch (std::exception ex) - { - return -1; - } - return 0; +#include +#include "ArgumentQueue.h" + +int main(int argc, char *argv[]) +{ + SDDS::ArgumentQueue argQueue; + if (argc <= 1) + { + std::cout << "At least specify an input file. \nPlease run -h or --help for help " << std::endl; + return -1; + } + for (int i = 1; i < argc; i++) + { + if (argv[i][0] == '-' || argv[i][0] == '/' || argv[i][0] == '\\') + { + argQueue.addArg(argv[i], argv[i + 1]); + } + } + try + { + argQueue.execute(); + } + catch (std::exception ex) + { + return -1; + } + return 0; } \ No newline at end of file