33#include < argparse/argparse.hpp>
44#include < string_view>
55
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+
810
911namespace CppSpec {
12+
1013constexpr std::string file_name (std::string_view path) {
1114 std::string_view file = path;
1215 for (size_t i = 0 ; i < path.size (); ++i) {
@@ -17,15 +20,9 @@ constexpr std::string file_name(std::string_view path) {
1720 return std::string{file};
1821}
1922
20- enum class Formatter {
21- Progress,
22- TAP,
23- Detail
24- };
25-
2623struct RuntimeOpts {
2724 bool verbose = false ;
28- Formatter format = Formatter::Progress ;
25+ std::unique_ptr<Formatters::BaseFormatter> formatter = nullptr ;
2926};
3027
3128inline RuntimeOpts parse (int argc, char ** argv) {
@@ -55,13 +52,18 @@ inline RuntimeOpts parse(int argc, char** argv) {
5552 opts.verbose = true ;
5653 }
5754
58- auto format_string = program.get <std::string>(" --format" );
55+ auto format_string = program.get <std::string>(" --format" );
5956 if (format_string == " p" || format_string == " progress" ) {
60- opts.format = Formatter:: Progress;
57+ opts.formatter = std::make_unique<Formatters:: Progress>() ;
6158 } else if (format_string == " t" || format_string == " tap" ) {
62- opts.format = Formatter:: TAP;
59+ opts.formatter = std::make_unique<Formatters:: TAP>() ;
6360 } 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 );
6565 }
66+
67+ return opts;
6668}
6769} // namespace CppSpec
0 commit comments