From b38bb60e6217576c2a70a8362db0e1e05c36b3a4 Mon Sep 17 00:00:00 2001 From: Preston Date: Tue, 28 Oct 2025 17:19:27 -0700 Subject: [PATCH] added try and catch --- lib/commandLineParser.h | 80 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 lib/commandLineParser.h diff --git a/lib/commandLineParser.h b/lib/commandLineParser.h new file mode 100644 index 0000000..88c9a09 --- /dev/null +++ b/lib/commandLineParser.h @@ -0,0 +1,80 @@ +/** + * @file commandLineParser.h + * @brief Parses command line + * @author Preston Shultz + * Sources: + * + */ + +#ifndef COMMAND_LINE_PARSER_H +#define COMMAND_LINE_PARSER_H + +#include +#include + +/** + * @brief CommandLine Helper class + * + * Parse input arguments, sets input and output files + * Lets user use commands with program + * + * @author Preston Shultz (shultzp1@my.erau.edu) + */ +class CLI{ +public: + /** + * @brief Takes in argc and argv and converts it to vector + * + * CLI constructor + * + * @author Preston Shultz (shultzp1@my.erau.edu) + */ + CLI(int argc, char **argv); + + /** + * @brief Runs Commands + * + * @author Preston Shultz (shultzp1@my.erau.edu) + */ + void RunCommands(); + + /** + * @brief Prints a list of commands that can be used + * + * @author Preston Shultz (shultzp1@my.erau.edu) + */ + void PrintHelp() const; + + /** + * @brief Returns input file + * + * @author Preston Shultz (shultzp1@my.erau.edu) + */ + std::string GetInputFile() const {return inputFile;} + + /** + * @brief Returns output file + * + * @author Preston Shultz (shultzp1@my.erau.edu) + */ + std::string GetOutputFile() const {return outputFile;} + +private: + + /** + * @brief Ensures the provided filename has a .markup extension + * + * @param filename The file name to validate + * @return true if file ends with .markup + * @return false otherwise + * @author Preston Shultz (shultzp1@my.erau.edu) + */ + static bool IsMarkupFile(const std::string& filename); + + std::string programName; + std::vector args; + std::string inputFile; + std::string outputFile; +}; + +#endif \ No newline at end of file