summaryrefslogtreecommitdiff
path: root/tests/combined/driver.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-04-01 18:37:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-04-01 18:37:30 +0200
commitbffe74e67f69fb4ad928230e86ca776bd39ae432 (patch)
tree93cddb51d4ffc27177ee36d17bb086434de5452e /tests/combined/driver.cxx
parentfc98bf23c16baf836d2c841792d4e0b35dd82727 (diff)
Implement combined flags (-xyz vs -x -y -z) and values (--foo=bar) support
Both are enabled by default but can be disable with --no-combined-flags and --no-combined-values options.
Diffstat (limited to 'tests/combined/driver.cxx')
-rw-r--r--tests/combined/driver.cxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/combined/driver.cxx b/tests/combined/driver.cxx
new file mode 100644
index 0000000..e6f27e4
--- /dev/null
+++ b/tests/combined/driver.cxx
@@ -0,0 +1,40 @@
+// file : tests/combined/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC
+// 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;
+ }
+}