3
3
#include < argparse/argparse.hpp>
4
4
#include < string_view>
5
5
6
- #include " argparse.hpp"
7
- #include " formatters/formatters_base.hpp"
6
+ #include " formatters/progress.hpp"
7
+ #include " formatters/tap.hpp"
8
+ #include " formatters/verbose.hpp"
9
+
8
10
9
11
namespace CppSpec {
12
+
10
13
constexpr std::string file_name (std::string_view path) {
11
14
std::string_view file = path;
12
15
for (size_t i = 0 ; i < path.size (); ++i) {
@@ -17,15 +20,9 @@ constexpr std::string file_name(std::string_view path) {
17
20
return std::string{file};
18
21
}
19
22
20
- enum class Formatter {
21
- Progress,
22
- TAP,
23
- Detail
24
- };
25
-
26
23
struct RuntimeOpts {
27
24
bool verbose = false ;
28
- Formatter format = Formatter::Progress ;
25
+ std::unique_ptr<Formatters::BaseFormatter> formatter = nullptr ;
29
26
};
30
27
31
28
inline RuntimeOpts parse (int argc, char ** argv) {
@@ -55,13 +52,18 @@ inline RuntimeOpts parse(int argc, char** argv) {
55
52
opts.verbose = true ;
56
53
}
57
54
58
- auto format_string = program.get <std::string>(" --format" );
55
+ auto format_string = program.get <std::string>(" --format" );
59
56
if (format_string == " p" || format_string == " progress" ) {
60
- opts.format = Formatter:: Progress;
57
+ opts.formatter = std::make_unique<Formatters:: Progress>() ;
61
58
} else if (format_string == " t" || format_string == " tap" ) {
62
- opts.format = Formatter:: TAP;
59
+ opts.formatter = std::make_unique<Formatters:: TAP>() ;
63
60
} else if (format_string == " d" || format_string == " detail" ) {
64
- opts.format = Formatter::Detail;
61
+ opts.formatter = std::make_unique<Formatters::Verbose>();
62
+ } else {
63
+ std::cerr << " Unrecognized format type" << std::endl;
64
+ std::exit (-1 );
65
65
}
66
+
67
+ return opts;
66
68
}
67
69
} // namespace CppSpec
0 commit comments