From: Fabian Fichter Date: Mon, 28 Mar 2022 18:52:08 +0000 (+0200) Subject: Support variant config parsing on CLI X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=647853cd9eba78fb3db3d0499c6fc36567253229;p=fairystockfish.git Support variant config parsing on CLI Use here-docs to load variant configurations from the CLI. ``` load <> std::ws, token); - std::size_t end = token.find_last_not_of(' '); - if (end != std::string::npos) - Options["VariantPath"] = token.erase(end + 1); + + // The argument to load either is a here-doc or a file path + if (token.rfind("<<", 0) == 0) + { + // Trim the EOF marker + if (!(stringstream(token.substr(2)) >> token)) + token = ""; + + // Parse variant config till EOF marker + stringstream ss; + std::string line; + while (std::getline(cin, line) && line != token) + ss << line << std::endl; + variants.parse_istream(ss); + Options["UCI_Variant"].set_combo(variants.get_keys()); + } + else + { + // store path if non-empty after trimming + std::size_t end = token.find_last_not_of(' '); + if (end != std::string::npos) + Options["VariantPath"] = token.erase(end + 1); + } } // check() is called when engine receives the "check" command.