7
7
#include < random>
8
8
#include < string>
9
9
#include < thread>
10
+ #include " utils.hpp"
10
11
#include " str_format.hpp"
11
12
#include < dumb_json/djson.hpp>
12
13
@@ -20,19 +21,7 @@ void sleep(int ms)
20
21
std::this_thread::sleep_for (std::chrono::milliseconds (ms));
21
22
}
22
23
23
- enum class Color
24
- {
25
- BLACK = 0 ,
26
- RED = 1 ,
27
- GREEN = 2 ,
28
- YELLOW = 3 ,
29
- BLUE = 4 ,
30
- MAGENTA = 5 ,
31
- CYAN = 6 ,
32
- WHITE = 7
33
- };
34
-
35
- std::string style (std::string text, Color fore, Color back = Color::BLACK)
24
+ std::string style (std::string text, Color fore, Color back)
36
25
{
37
26
// add fore and background ground color to text
38
27
std::string ansi_text = kt::format_str (" \x1B [3{}m" , static_cast <int >(fore));
@@ -45,7 +34,7 @@ std::string style(std::string text, Color fore, Color back = Color::BLACK)
45
34
return ansi_text.append (kt::format_str (" {}\033 [0m" , text));
46
35
}
47
36
48
- std::filesystem::path find_upwards (std::string dir_name, int max_depth = 10 )
37
+ std::filesystem::path find_upwards (std::string dir_name, int max_depth)
49
38
{
50
39
auto path = std::filesystem::current_path () / std::filesystem::path (dir_name);
51
40
@@ -79,24 +68,26 @@ std::vector<std::string> read_file(const std::filesystem::path& path)
79
68
return lines;
80
69
}
81
70
82
- bool check_manifest (const std::filesystem::path& path)
71
+ Manifest check_manifest (const std::filesystem::path& path)
83
72
{
84
- bool game_ready = false ;
73
+ Manifest manifest{} ;
85
74
86
75
if (std::filesystem::exists (path))
87
76
{
88
- auto manifest = read_file (path);
89
- auto json = std::accumulate (manifest .begin (), manifest .end (), std::string (" " ));
77
+ auto file = read_file (path);
78
+ auto json = std::accumulate (file .begin (), file .end (), std::string (" " ));
90
79
if (auto n = dj::node_t::make (json))
91
80
{
92
81
dj::node_t & node = *n;
93
- game_ready = node[" game_ready" ].as <bool >();
82
+ manifest.game_ready = node[" game_ready" ].as <bool >();
83
+ manifest.duplicates = node[" duplicates" ].as <std::vector<int >>();
84
+ manifest.files = node[" files" ].as <std::vector<std::string>>();
94
85
}
95
86
}
96
87
else
97
88
{
98
89
std::cerr << " File not found: " << path.string () << ' \n ' ;
99
90
}
100
91
101
- return game_ready ;
92
+ return manifest ;
102
93
}
0 commit comments