print usage
This commit is contained in:
parent
2bf1060d0b
commit
c8b22d113d
@ -396,7 +396,8 @@ Options::help() const
|
|||||||
|
|
||||||
size_t longest = 0;
|
size_t longest = 0;
|
||||||
|
|
||||||
std::string result;
|
std::string result = "Usage:\n " + m_program + " [OPTION...] "
|
||||||
|
+ m_help_string + "\n\n";
|
||||||
|
|
||||||
for (const auto& o : group->second)
|
for (const auto& o : group->second)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -329,6 +329,12 @@ namespace cxxopts
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
Options(std::string program, std::string help_string = "")
|
||||||
|
: m_program(std::move(program))
|
||||||
|
, m_help_string(std::move(help_string))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
parse(int& argc, char**& argv);
|
parse(int& argc, char**& argv);
|
||||||
|
|
||||||
@ -410,6 +416,9 @@ namespace cxxopts
|
|||||||
const std::string& name
|
const std::string& name
|
||||||
);
|
);
|
||||||
|
|
||||||
|
std::string m_program;
|
||||||
|
std::string m_help_string;
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<OptionDetails>> m_options;
|
std::map<std::string, std::shared_ptr<OptionDetails>> m_options;
|
||||||
std::string m_positional;
|
std::string m_positional;
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@ int main(int argc, char* argv[])
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
cxxopts::Options options;
|
cxxopts::Options options(argv[0]);
|
||||||
|
|
||||||
options.add_options()
|
options.add_options()
|
||||||
("a,apple", "an apple")
|
("a,apple", "an apple")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user