From 720c5a33b6a49cf328fdd7611f49153cf8f60247 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 8 Apr 2020 14:51:57 +0300 Subject: Separate tests and examples into individual packages Also make cli module to be explicitly enabled via the config.cli configuration variable. --- examples/features/.gitignore | 1 - examples/features/README | 20 -------------- examples/features/buildfile | 8 ------ examples/features/driver.cxx | 61 ------------------------------------------- examples/features/options.cli | 39 --------------------------- 5 files changed, 129 deletions(-) delete mode 100644 examples/features/.gitignore delete mode 100644 examples/features/README delete mode 100644 examples/features/buildfile delete mode 100644 examples/features/driver.cxx delete mode 100644 examples/features/options.cli (limited to 'examples/features') diff --git a/examples/features/.gitignore b/examples/features/.gitignore deleted file mode 100644 index c6e608b..0000000 --- a/examples/features/.gitignore +++ /dev/null @@ -1 +0,0 @@ -options.?xx diff --git a/examples/features/README b/examples/features/README deleted file mode 100644 index 9416320..0000000 --- a/examples/features/README +++ /dev/null @@ -1,20 +0,0 @@ -This example shows how to use various features of the CLI language. - -The example consists of the following files: - -options.cli - Command line interface description in the CLI language. - -options.hxx -options.ixx -options.cxx - Command line interface implementation in C++. These files are generated - by the CLI compiler from hello.cli using the following command line: - - cli options.cli - -driver.cxx - Driver for the example. It first instantiates the option class which parses - the command line. The driver then examines and prints the option values. - -To run the example you can try various command lines suggested in options.cli. diff --git a/examples/features/buildfile b/examples/features/buildfile deleted file mode 100644 index 29ce2c7..0000000 --- a/examples/features/buildfile +++ /dev/null @@ -1,8 +0,0 @@ -# file : examples/features/buildfile -# license : MIT; see accompanying LICENSE file - -exe{driver}: {hxx cxx}{* -options} cli.cxx{options} doc{README} - -cxx.poptions =+ "-I$out_base" - -cli.cxx{options}: cli{options} diff --git a/examples/features/driver.cxx b/examples/features/driver.cxx deleted file mode 100644 index 33ba362..0000000 --- a/examples/features/driver.cxx +++ /dev/null @@ -1,61 +0,0 @@ -// file : examples/features/driver.cxx -// author : Boris Kolpackov -// license : MIT; see accompanying LICENSE file - -#include -#include -#include - -#include "options.hxx" - -using namespace std; - -int -main (int argc, char* argv[]) -{ - try - { - features::options o (argc, argv); - - // --out-dir | -o - // - if (!o.out_dir ().empty ()) - cerr << "output dir: " << o.out_dir () << endl; - - // --first-name & --last-name - // - cerr << "first name: " << o.first_name () << endl - << "last name : " << o.last_name () << endl; - - // --vector | -v & --set | -s - // - if (!o.vector ().empty ()) - { - copy (o.vector ().begin (), o.vector ().end (), - ostream_iterator (cerr, " ")); - cerr << endl; - } - - if (!o.set ().empty ()) - { - copy (o.set ().begin (), o.set ().end (), - ostream_iterator (cerr, " ")); - cerr << endl; - } - - // --map | -m - // - typedef map str_map; - const str_map& m = o.map (); - str_map::const_iterator i (m.find ("a")); - - if (i != m.end ()) - cerr << "value for the 'a' key: " << i->second << endl; - - } - catch (const cli::exception& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/examples/features/options.cli b/examples/features/options.cli deleted file mode 100644 index ea055b3..0000000 --- a/examples/features/options.cli +++ /dev/null @@ -1,39 +0,0 @@ -include ; -include ; -include ; -include ; - -// 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 --vector | -v; - std::set --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 --map | -m; - }; -} -- cgit v1.1