/* Copyright © 2016 Taylor C. Richberger * This code is released under the license described in the LICENSE file */ #include #include #include #include int main(int argc, char **argv) { setlocale(LC_ALL, ""); args::ArgumentParser parser("This is a test program. It has a lot of really cool things about it, and it also has a really really long description line that is going to necessitate some line breaks.", "As you saw above, this previously mentioned program has a lot of long things, and therefore necessitates some line breaking"); args::Group mutexgroup(parser, "Group test", args::Group::Validators::AllOrNone); args::Flag aflag(mutexgroup, "a", "This is flag a", args::Matcher({'a'})); args::Flag bflag(mutexgroup, "b", "This is flag b", args::Matcher({'b'})); args::Flag cflag(mutexgroup, "c", "This is flag c", args::Matcher({'c'})); args::HelpFlag help(parser, "help", "Display this help menu", args::Matcher({'h'}, {"help"})); args::Flag fooflag(parser, "foo", "This is a foo flag", args::Matcher({'f', 'F'}, {"Foo", "foo"})); args::ArgFlag bararg(parser, "bar", "This is a bar flag", args::Matcher({'b', 'B'}, {"Bar", "bar"})); args::ArgFlag baz(parser, "baz", "This is a baz flag", args::Matcher({'z', 'Z'}, {"Baz", "baz"})); args::ArgFlagList list(parser, "flaglist", "This is a list flag", args::Matcher({'l'}, {"list"})); args::PosArg pos(parser, "Position", "This is a position arg"); args::PosArg pos2(parser, "Position", "This is a position arg"); args::PosArg pos3(parser, "Position", "This is a position arg"); args::PosArg pos4(parser, "Pösitiön", "This is a position arg"); args::PosArg pos5(parser, "Position", "This is a position arg"); args::PosArg pos6(parser, "Position", "This is a position arg"); args::PosArgList poslist1(parser, "Position list", "This is a position list arg"); args::PosArgList poslist2(parser, "Position list", "This is a position list arg"); args::PosArgList poslist3(parser, "Position list", "This is a position list arg"); args::PosArg pos7(parser, "Position", "This is a position arg"); args::PosArg pos8(parser, "Position", "This is a position arg"); args::PosArgList poslist4(parser, "Position list", "This is a position list arg"); args::PosArg pos9(parser, "Position", "This is a position arg"); args::PosArgList poslist(parser, "Position list", "This is a position list arg"); args::Counter counter(parser, "counter", "This is a counter flag", args::Matcher({'c'})); try { parser.ParseCLI(argc, argv); } catch (args::Help) { std::cout << parser.Help(); return 0; } catch (args::ParseError e) { std::cerr << e.what() << std::endl; std::cerr << parser.Help(); return 1; } if (aflag) { std::cout << "A flag found" << std::endl; } if (bflag) { std::cout << "B flag found" << std::endl; } if (cflag) { std::cout << "C flag found" << std::endl; } if (fooflag) { std::cout << "Foo flag found" << std::endl; } if (bararg) { std::cout << "Bar arg found: " << bararg.Value() << std::endl; } if (baz) { std::cout << "Baz arg found: " << baz.Value() << std::endl; } if (counter) { std::cout << "counter found: " << counter.Count() << std::endl; } if (list) { std::cout << "list found: " << std::endl; for (const auto &item: list.Values()) { std::cout << "- " << item << std::endl; } } if (pos) { std::cout << "pos found: " << pos.Value() << std::endl; } if (poslist) { std::cout << "poslist found: " << std::endl; for (const auto &item: poslist.Values()) { std::cout << "- " << item << std::endl; } } return 0; }