Line |
Branch |
Exec |
Source |
1 |
|
|
#ifndef COMMAND_LINE_PARSER_HPP |
2 |
|
|
#define COMMAND_LINE_PARSER_HPP |
3 |
|
|
|
4 |
|
|
#include <map> |
5 |
|
|
#include <optional> |
6 |
|
|
#include <string> |
7 |
|
|
#include <vector> |
8 |
|
|
|
9 |
|
|
|
10 |
|
|
class CommandLineParser { |
11 |
|
|
|
12 |
|
|
private: |
13 |
|
|
std::vector<std::string> args; |
14 |
|
|
std::map<std::string, std::tuple<std::string, std::string, std::optional<std::string>>> options; |
15 |
|
|
|
16 |
|
|
public: |
17 |
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 |
CommandLineParser(const int argc, char **argv) { args.assign(argv, argv + argc); } |
18 |
|
|
|
19 |
|
|
void addOption(const std::string &longOpt, const std::string &shortOpt, const std::string &description); |
20 |
|
|
|
21 |
|
|
void parse(); |
22 |
|
|
|
23 |
|
|
[[nodiscard]] std::optional<std::string> getOption(const std::string &longOpt) const; |
24 |
|
|
|
25 |
|
|
void displayHelp(const std::string &binaryName) const; |
26 |
|
|
}; |
27 |
|
|
|
28 |
|
|
#endif //COMMAND_LINE_PARSER_HPP |
29 |
|
|
|