diff options
Diffstat (limited to 'cli-tests/position/driver.cxx')
-rw-r--r-- | cli-tests/position/driver.cxx | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/cli-tests/position/driver.cxx b/cli-tests/position/driver.cxx new file mode 100644 index 0000000..77b9a8d --- /dev/null +++ b/cli-tests/position/driver.cxx @@ -0,0 +1,38 @@ +// file : position/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// license : MIT; see accompanying LICENSE file + +// Test argument/option position. +// +#include <iostream> + +#include "test.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + try + { + cli::argv_file_scanner scan (argc, argv, "--file"); + options ops (scan); + + if (ops.a_specified ()) + cout << ops.a ().second << ": " << "-a " << ops.a ().first << endl; + + for (const pair<int, size_t>& b: ops.b ()) + { + cout << b.second << ": " << "-b " << b.first << endl; + } + + while (scan.more ()) + cout << scan.position () << ": " << scan.next () << endl; + + cout << "max: " << scan.position () << endl; + } + catch (const cli::exception& e) + { + cerr << e << endl; + } +} |