Simplify reading
This commit is contained in:
parent
872d004b64
commit
e798e30cf2
2 changed files with 4 additions and 5 deletions
|
@ -115,9 +115,9 @@ void process_escapes(std::string& input) {
|
||||||
input.resize(output_idx);
|
input.resize(output_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json get_json(std::string& file_name) noexcept {
|
nlohmann::json get_json(const char* file_name) noexcept {
|
||||||
try {
|
try {
|
||||||
printf("Opening a json file %s\n", file_name.c_str());
|
printf("Opening a json file %s\n", file_name);
|
||||||
std::ifstream jstream(file_name);
|
std::ifstream jstream(file_name);
|
||||||
return nlohmann::json::parse(jstream);
|
return nlohmann::json::parse(jstream);
|
||||||
}
|
}
|
||||||
|
@ -136,8 +136,7 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
|
||||||
// only the second argument to reduce reading attempts (plus drag'n'drop)
|
// only the second argument to reduce reading attempts (plus drag'n'drop)
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
// console arguments should override json values, so json processing goes first
|
// console arguments should override json values, so json processing goes first
|
||||||
std::string json_name = argv[1];
|
nlohmann::json file_config = get_json(argv[1]);
|
||||||
nlohmann::json file_config = get_json(json_name);
|
|
||||||
pos = 2; // avoid putting file name into arguments
|
pos = 2; // avoid putting file name into arguments
|
||||||
if (!file_config.empty()) {
|
if (!file_config.empty()) {
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ struct gpt_params {
|
||||||
std::string image = ""; // path to an image file
|
std::string image = ""; // path to an image file
|
||||||
};
|
};
|
||||||
|
|
||||||
nlohmann::json get_json(std::string& file_name) noexcept;
|
nlohmann::json get_json(const char* file_name) noexcept;
|
||||||
|
|
||||||
bool gpt_params_parse_ex(int argc, char ** argv, gpt_params & params);
|
bool gpt_params_parse_ex(int argc, char ** argv, gpt_params & params);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue