#pragma once #include #include #include #include "utils/option.hpp" namespace { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-function" auto all_arguments(int argc, char *argv[]) { return std::vector(argv + 1, argv + argc); } bool contains_argument(const std::vector &all, const std::string &flag) { return std::find(all.begin(), all.end(), flag) != all.end(); } auto get_argument(const std::vector &all, const std::string &flag, const std::string &default_value) { auto it = std::find(all.begin(), all.end(), flag); if (it == all.end()) return default_value; return all[std::distance(all.begin(), it) + 1]; } Option take_argument(std::vector &all, const std::string &flag) { auto it = std::find(all.begin(), all.end(), flag); if (it == all.end()) return make_option(); auto s = std::string(all[std::distance(all.begin(), it) + 1]); it++; it++; all.erase(std::find(all.begin(), all.end(), flag), it); return make_option(std::move(s)); } #pragma clang diagnostic pop }