| 114 | } |
| 115 | |
| 116 | bool common_arg::get_value_from_env(std::string & output) const { |
| 117 | if (env == nullptr) return false; |
| 118 | if (!args_neg.empty()) { |
| 119 | // for compatibility, we need to check LLAMA_ARG_NO_ env as well |
| 120 | std::string neg_env = env; |
| 121 | string_replace_all(neg_env, "LLAMA_ARG_", "LLAMA_ARG_NO_"); |
| 122 | char * neg_value = std::getenv(neg_env.c_str()); |
| 123 | if (neg_value) { |
| 124 | output = "0"; // falsey |
| 125 | return true; |
| 126 | } |
| 127 | } |
| 128 | char * value = std::getenv(env); |
| 129 | if (value) { |
| 130 | output = value; |
| 131 | return true; |
| 132 | } |
| 133 | return false; |
| 134 | } |
| 135 | |
| 136 | bool common_arg::has_value_from_env() const { |
| 137 | if (env != nullptr && !args_neg.empty()) { |
no test coverage detected