25 const char *val = std::getenv(env_var);
27 return std::string(val);
33std::vector<std::pair<std::string, std::string>>
env_var_reg = {};
38 if (_env_var == env_var) {
40 shambase::format(
"The env var {} is already registered", env_var));
53 auto stringify = [](std::optional<std::string> val) -> std::string {
55 return shambase::format(
"= {}", *val);
60 fmt::println(
"\nEnv variables :");
std::vector< std::pair< std::string, std::string > > env_var_reg
List of documented env variables.
void println(std::string_view sv)
Prints a string to the console followed by a newline.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
std::optional< std::string > getenv_str(const char *env_var)
Get the content of the environment variable if it exist.
void print_help_env_var()
Print the documentation of the environment variables registered with register_env_var_doc()
void register_env_var_doc(std::string env_var, std::string desc)
Register the documentation of an environment variable.