diff options
Diffstat (limited to 'cli-tests/combined/driver.cxx')
-rw-r--r-- | cli-tests/combined/driver.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/cli-tests/combined/driver.cxx b/cli-tests/combined/driver.cxx new file mode 100644 index 0000000..dcbdd34 --- /dev/null +++ b/cli-tests/combined/driver.cxx @@ -0,0 +1,39 @@ +// file : combined/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// license : MIT; see accompanying LICENSE file + +// Test combined flags (-xyz vs -x -y -z) and option values (--foo=bar). +// + +#include <iostream> + +#include "test.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + try + { + cli::argv_file_scanner s (argc, argv, "--file"); + options o (s); + + if (o.foo_specified ()) + cout << "--foo=" << o.foo () << endl; + + if (o.x () || o.y () || o.z ()) + cout << '-' + << (o.x () ? "x" : "") + << (o.y () ? "y" : "") + << (o.z () ? "z" : "") << endl; + + if (o.xyz ()) + cout << "--xyz" << endl; + } + catch (const cli::exception& e) + { + cerr << e << endl; + return 1; + } +} |