summaryrefslogtreecommitdiff
path: root/cli-examples/features/options.cli
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-04-08 14:51:57 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-04-27 11:38:53 +0300
commit720c5a33b6a49cf328fdd7611f49153cf8f60247 (patch)
tree9725f3d1f42ec90fde84520f49647edea013ce5e /cli-examples/features/options.cli
parent3183f3bb927a90783ae0aeaf190a0919377aabe4 (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-examples/features/options.cli')
-rw-r--r--cli-examples/features/options.cli39
1 files changed, 39 insertions, 0 deletions
diff --git a/cli-examples/features/options.cli b/cli-examples/features/options.cli
new file mode 100644
index 0000000..ea055b3
--- /dev/null
+++ b/cli-examples/features/options.cli
@@ -0,0 +1,39 @@
+include <set>;
+include <map>;
+include <vector>;
+include <string>;
+
+// We can place the options classes into namespaces which mapped to C++
+// namespaces.
+//
+namespace features
+{
+ class options
+ {
+ // We can have several aliases for the same option. The first one is used
+ // to derive the accessor name.
+ //
+ std::string --out-dir | -o;
+
+ // We can use both assignment and constructor notations to provide the
+ // default option value.
+ //
+ std::string --first-name = "John";
+ std::string --last-name ("Mr John Doe", 8, 3);
+
+ // We can use containers to to collect option value. If we have a command
+ // line like this: -v 1 -v 2 -v 1 -s 1 -s 2 -s 1 then the vector returned
+ // by the vector() accessor will contain three elements: 1, 2, and 1 while
+ // the set returned by the set() accessor will contain two elements: 1 and
+ // 2.
+ //
+ std::vector<int> --vector | -v;
+ std::set<int> --set | -s;
+
+ // We can also use maps. In this case the option value is expected to have
+ // two parts: the key and the value, separated by '='. For example: -m a=A
+ // -m =B -m c= -m d (same as -m d=).
+ //
+ std::map<std::string, std::string> --map | -m;
+ };
+}