diff --git a/README b/README new file mode 100644 index 0000000..04b1af8 --- /dev/null +++ b/README @@ -0,0 +1,49 @@ +This is a lightweight C++ option parser library, supporting the standard GNU +style syntax for options. + +Options can be given as: + + --long + --long=argument + --long argument + -a + -ab + -abc argument + +where c takes an argument, but a and b do not. + +How to use: + + #include + +Create a cxxopts::Options instance. + + cxxopts::Options options; + +Then use add_options. + + options.add_options() + ("d,debug", "Enable debugging") + ("f,file", "File name", cxxopts::value()) + +Options can be declared with a short and/or long option. A description must be +provided. The third argument is the value, if omitted it is boolean. + +To parse the command line do: + + options.parse(argc, argv); + +To retrieve an option use options.count("option") to get the number of times +it appeared, and + + options["opt"].as() + +to get its value. If "opt" doesn't exist, or isn't of the right type, then an +exception will be thrown. + + +== TODO list == + +* Remove parsed options. +* Allow unrecognised options. +* Multiple occurences of options store in vector.