arg: Add comment line support to --api-key-file (#23168)

This commit is contained in:
Mikolaj Kucharski
2026-06-19 17:33:54 +02:00
committed by GitHub
parent 0d2d9ccbf6
commit fabde3bf51
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -2911,7 +2911,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
).set_examples({LLAMA_EXAMPLE_SERVER}).set_env("LLAMA_API_KEY"));
add_opt(common_arg(
{"--api-key-file"}, "FNAME",
"path to file containing API keys (default: none)",
"path to file containing API keys, one per line; lines starting with a hash are treated as comments (default: none)",
[](common_params & params, const std::string & value) {
std::ifstream key_file(value);
if (!key_file) {
@@ -2919,7 +2919,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
}
std::string key;
while (std::getline(key_file, key)) {
if (!key.empty()) {
if (!key.empty() && key[0] != '#') {
params.api_keys.push_back(key);
}
}