18 for (
int i = 1; i < argc; ++i)
20 std::string arg = argv[i];
22 if (arg ==
"-h" || arg ==
"--help")
28 if (arg ==
"-v" || arg ==
"--version")
34 if (arg ==
"-c" || arg ==
"--config")
38 throw std::runtime_error(
"Missing value for argument " + arg);
45 throw std::runtime_error(
"Unknown argument: " + arg +
". Use -h or --help to see available options.");
57 if (envMap.contains(
"USER"))
61 if (envMap.contains(
"PWD"))
63 config.
pwd = envMap.at(
"PWD");
This file contains the ArgsHandler class declaration.
This file contains env utility functions.
static ArgsConfig ParseArgs(int argc, const char *const *argv)
Parse command line arguments.
static EnvConfig ParseEnv(const char *const *envp)
Parse environment variables.
This file contains the common definitions.
static constexpr std::string_view VERSION_MSG
static constexpr std::string_view HELP_MSG
std::unordered_map< std::string, std::string > getEnvMap(const char *const *env)
Get environment variables as a map.
Struct for command line arguments configuration.
Struct for environment variables configuration.