diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-04-08 14:51:57 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-04-27 11:38:53 +0300 |
commit | 720c5a33b6a49cf328fdd7611f49153cf8f60247 (patch) | |
tree | 9725f3d1f42ec90fde84520f49647edea013ce5e /cli-tests/group/driver.cxx | |
parent | 3183f3bb927a90783ae0aeaf190a0919377aabe4 (diff) |
Separate tests and examples into individual packages
Also make cli module to be explicitly enabled via the config.cli configuration
variable.
Diffstat (limited to 'cli-tests/group/driver.cxx')
-rw-r--r-- | cli-tests/group/driver.cxx | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/cli-tests/group/driver.cxx b/cli-tests/group/driver.cxx new file mode 100644 index 0000000..68f6107 --- /dev/null +++ b/cli-tests/group/driver.cxx @@ -0,0 +1,58 @@ +// file : group/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// license : MIT; see accompanying LICENSE file + +// Test group_scanner. +// + +#include <iostream> + +#include "test.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + try + { + using namespace cli; + + // Mode flags. + // + // 'g' -- don't handle groups. + // 's' -- skip arguments. + // + string m (argv[1]); + + argv_scanner as (--argc, ++argv); + group_scanner s (as); + + while (s.more ()) + { + if (m.find ('s') == string::npos) + { + const char* a (s.next ()); + cout << "'" << a << "'"; + } + else + s.skip (); + + if (m.find ('g') == string::npos) + { + scanner& gs (s.group ()); + while (gs.more ()) + cout << " '" << gs.next () << "'"; + } + + cout << endl; + } + + return 0; + } + catch (const cli::exception& e) + { + cerr << e << endl; + return 1; + } +} |