diff options
author | Pavel Belikov <pavel.fuchs.belikov@gmail.com> | 2017-12-23 21:07:26 +0300 |
---|---|---|
committer | Pavel Belikov <pavel.fuchs.belikov@gmail.com> | 2017-12-23 21:07:26 +0300 |
commit | 4b983b8f035dbd854edc3fd50c767d913bf775ad (patch) | |
tree | 6ce5b4ed6fddd56ff6a366c537a02bd8fa196630 /examples/completion.cxx | |
parent | fix bash equal sign tokenization (diff) | |
download | args.hxx-4b983b8f035dbd854edc3fd50c767d913bf775ad.tar.xz |
add examples
Diffstat (limited to 'examples/completion.cxx')
-rw-r--r-- | examples/completion.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/completion.cxx b/examples/completion.cxx new file mode 100644 index 0000000..3122c30 --- /dev/null +++ b/examples/completion.cxx @@ -0,0 +1,27 @@ +/* Copyright © 2016-2017 Taylor C. Richberger <taywee@gmx.com> and Pavel Belikov + * This code is released under the license described in the LICENSE file + */ + +#include "args.hxx" +#include <iostream> + +int main(int argc, const char **argv) +{ + args::ArgumentParser p("parser"); + args::CompletionFlag c(p, {"complete"}); + args::ValueFlag<std::string> f(p, "name", "description", {'f', "foo"}, "abc"); + args::ValueFlag<std::string> b(p, "name", "description", {'b', "bar"}, "abc"); + args::MapFlag<std::string, int> m(p, "mappos", "mappos", {'m', "map"}, {{"1",1}, {"2", 2}}); + args::Positional<std::string> pos(p, "name", "desc"); + + try + { + p.ParseCLI(argc, argv); + } + catch (args::Completion &e) + { + std::cout << e.what(); + } + + return 0; +} |