#pragma once #include #include #include #include namespace izo { class CommandLine { public: CommandLine(int argc, const char* const argv[]); CommandLine(int argc, char* argv[]); // Has reports whether an option was supplied, including --name=value. bool Has(std::string_view name) const noexcept; // Get returns the last value supplied as --name value or --name=value. // A flag without a value and a missing option both return std::nullopt. std::optional Get(std::string_view name) const; std::string Get(std::string_view name, std::string_view fallback) const; int GetInt(std::string_view name, int fallback) const; // Arguments not consumed as option values. argv[0] is never included. const std::vector& Positionals() const noexcept { return positionals_; } private: struct Option { std::string name; std::optional value; }; void Parse(int argc, const char* const argv[]); std::vector