polybar-dwm/include/utils/cli.hpp

39 lines
1.3 KiB
C++
Raw Normal View History

#pragma once
2016-05-19 14:41:06 +00:00
#include <vector>
#include "exception.hpp"
namespace cli
{
DefineBaseException(CommandLineError);
2016-05-19 14:41:06 +00:00
struct Option
{
std::string flag_short;
std::string flag_long;
std::string placeholder;
std::string help;
std::vector<std::string> accept;
2016-06-21 01:59:43 +00:00
Option(std::string flag_short, std::string flag_long, std::string placeholder, std::vector<std::string> accept, std::string help)
2016-05-19 14:41:06 +00:00
: flag_short(flag_short), flag_long(flag_long), placeholder(placeholder), help(help), accept(accept){}
};
2016-06-21 01:59:43 +00:00
void add_option(std::string opt_short, std::string opt_long, std::string help);
void add_option(std::string opt_short, std::string opt_long, std::string placeholder, std::string help, std::vector<std::string> accept = {});
2016-05-19 14:41:06 +00:00
2016-06-21 01:59:43 +00:00
bool is_option(char *opt, std::string opt_short, std::string opt_long);
bool is_option_short(char *opt, std::string opt_short);
bool is_option_long(char *opt, std::string opt_long);
2016-05-19 14:41:06 +00:00
std::string parse_option_value(int &i, int argc, char **argv, std::vector<std::string> accept = {});
2016-06-21 01:59:43 +00:00
bool has_option(std::string opt);
std::string get_option_value(std::string opt);
bool match_option_value(std::string opt, std::string val);
2016-05-19 14:41:06 +00:00
void parse(int i, int argc, char **argv);
2016-06-21 01:59:43 +00:00
void usage(std::string usage, bool exit_success = true);
2016-05-19 14:41:06 +00:00
}