File | Date | Author | Commit |
---|---|---|---|
examples | 2012-11-20 |
![]() |
[d09254] Added parseIndex feature. |
html | 2013-05-06 |
![]() |
[f08d8c] Adding ability to disable usage description emp... |
MIT-LICENSE | 2012-06-04 |
![]() |
[1d0ee7] Initial commit. |
Makefile | 2012-11-20 |
![]() |
[d09254] Added parseIndex feature. |
README.md | 2013-05-06 |
![]() |
[f08d8c] Adding ability to disable usage description emp... |
ezOptionParser.hpp | 2013-05-06 |
![]() |
[f08d8c] Adding ability to disable usage description emp... |
ezOptionParser is another command-line parser class for C++ that has features not available in alternative solutions (getopt, boost, argtable, argstream, gflags) and doesn't require a steep learning curve.
complete.cpp
A complete example that could be used as a starting point for your own C++ program.
fileio.cpp
Shows how to import and export options with files (that can contain comments!).
full.cpp
A full test of all the features. Meant for testing, but can be a source of ideas for what's possible.
long.cpp
Demo of using long flag names.
multi.cpp
Shows how to handle multiple instances of a flag.
parseindex.cpp
Demo of parsed indices for options, so you can create ordered contexts.
pretty.cpp
Demo of pretty printing everything parsed, which can help in debugging.
short.cpp
Short demo of a short flag name.
usage.cpp
Demo of automatic usage message creation in three builtin layouts.
Here are how the three layouts appear:
aligned, interleaved, staggered
valid.cpp
Demo of using validators defined by strings, which only check if values are within for their datatype limits.
validrange.cpp
Demo of using validators with value ranges and lists defined by strings.
validfast.cpp
Demo of using validators defined by constants for more efficient execution. These validators only check if values are within for their datatype limits..
validrangefast.cpp
Demo of using validators with value ranges and lists defined by constants for more efficient execution.
Copy or include ezOptionParser.hpp to your project and use the "ez" namespace, as shown here:
// pretty.cpp
#include <stdio.h>
#include "ezOptionParser.hpp"
int main(int argc, const char * argv[]) {
ez::ezOptionParser opt;
opt.overview = "Demo of pretty printing everything parsed.";
opt.syntax = "pretty [OPTIONS]";
opt.example = "pretty foo bar --debug --dummy -list 1,2,16 in1 in2 out\n\n";
opt.footer = "ezOptionParser (C) 2013\n";
opt.add(
"", // Default.
0, // Required?
0, // Number of args expected.
0, // Delimiter if expecting multiple args.
"Display usage instructions.", // Help description.
"-h", // Flag token.
"-help", // Flag token.
"--help", // Flag token.
"--usage" // Flag token.
);
opt.add(
"", // Default.
0, // Required?
0, // Number of args expected.
0, // Delimiter if expecting multiple args.
"Print all inputs and categories for debugging.", // Help description.
"--debug" // Flag token.
);
opt.parse(argc, argv);
if (opt.isSet("-h")) {
std::string usage;
opt.getUsage(usage);
std::cout << usage;
return 1;
}
if (opt.isSet("--debug")) {
std::string pretty;
opt.prettyPrint(pretty);
std::cout << pretty;
}
return 0;
}
Here is the auto-generated usage message:
./pretty -h
Demo of pretty printing everything parsed.
USAGE: pretty [OPTIONS]
OPTIONS:
-h, -help, --help, --usage Display usage instructions.
--debug Print all inputs and categories for debugging.
EXAMPLES:
pretty foo bar --debug --dummy -list 1,2,16 in1 in2 out
ezOptionParser (C) 2013
make
make memtest
make clean
sudo make install PREFIX=/usr/local
make html
make clean
make dist VER=0.2.1
ssh -t rsz,ezoptionparser@shell.sourceforge.net create
scp html/* ezOptionParser.hpp rsz,ezoptionparser@shell.sourceforge.net:/home/project-web/ezoptionparser/htdocs
scp ../ezOptionParser-0.2.1.tar.gz rsz,ezoptionparser@shell.sourceforge.net:/home/frs/project/e/ez/ezoptionparser
v0.2.1 (20130506)
v0.2.0 (20121120)
v0.1.4 (20120629)
v0.1.3 (20120603)
v0.1.2 (20111126)
v0.1.1 (20111011)
v0.1.0 (20111011)
v0.0.0 (20110511)
Copyright 2011, 2012 Remik Ziemlinski (see MIT-LICENSE)
<link rel="stylesheet" href="http://yandex.st/highlightjs/7.0/styles/default.min.css">
<script src="http://yandex.st/highlightjs/7.0/highlight.min.js"></script> <script>hljs.initHighlightingOnLoad();</script>