-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmisc_options.cpp
More file actions
51 lines (44 loc) · 1.14 KB
/
misc_options.cpp
File metadata and controls
51 lines (44 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* @file misc_options.cpp
* @brief Hidden miscellaneous CLI options handler (e.g., special outputs)
*/
#include "misc_options.h"
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
namespace seastack::app {
static std::string ReadAsciiFromFile(const std::string& path) {
std::ifstream file(path, std::ios::in | std::ios::binary);
if (!file.is_open()) {
return {};
}
std::ostringstream ss;
ss << file.rdbuf();
return ss.str();
}
static std::string LoadBannerAsset() {
const char* candidates[] = {
"./utils/term_layout.txt"
};
for (const char* c : candidates) {
std::string s = ReadAsciiFromFile(c);
if (!s.empty()) return s;
}
return {};
}
bool HandleHiddenOptions(int argc, char* argv[]) {
for (int i = 1; i < argc; ++i) {
std::string arg = argv[i];
if (arg == "--salter") {
std::string art = LoadBannerAsset();
if (art.empty()) {
return false;
}
std::cout << art << std::endl;
return true;
}
}
return false;
}
} // namespace seastack::app