summaryrefslogtreecommitdiff
path: root/examples/hello
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 /examples/hello
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 'examples/hello')
-rw-r--r--examples/hello/.gitignore1
-rw-r--r--examples/hello/README26
-rw-r--r--examples/hello/buildfile9
-rw-r--r--examples/hello/driver.cxx58
-rw-r--r--examples/hello/hello.cli18
5 files changed, 0 insertions, 112 deletions
diff --git a/examples/hello/.gitignore b/examples/hello/.gitignore
deleted file mode 100644
index d73130a..0000000
--- a/examples/hello/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-hello.?xx
diff --git a/examples/hello/README b/examples/hello/README
deleted file mode 100644
index dd14b01..0000000
--- a/examples/hello/README
+++ /dev/null
@@ -1,26 +0,0 @@
-This is a "Hello, world!" example that shows how to implement a very basic
-command line interface using CLI.
-
-The example consists of the following files:
-
-hello.cli
- Command line interface description in the CLI language.
-
-hello.hxx
-hello.ixx
-hello.cxx
- Command line interface implementation in C++. These files are generated
- by the CLI compiler from hello.cli using the following command line:
-
- cli hello.cli
-
-driver.cxx
- Driver for the example. It first instantiates the option class which parses
- the command line. The driver then examines the options and prints the
- greeting string for each name passed as an argument.
-
-To run the example you can try the following command lines:
-
-$ ./driver --help
-$ ./driver John Jane
-$ ./driver --greeting Hi --exclamations 3 John Jane
diff --git a/examples/hello/buildfile b/examples/hello/buildfile
deleted file mode 100644
index 9a11b29..0000000
--- a/examples/hello/buildfile
+++ /dev/null
@@ -1,9 +0,0 @@
-# file : examples/hello/buildfile
-# license : MIT; see accompanying LICENSE file
-
-exe{driver}: {hxx cxx}{* -hello} cli.cxx{hello} doc{README}
-exe{driver}: test.arguments = --greeting Hi John Jane
-
-cxx.poptions =+ "-I$out_base"
-
-cli.cxx{hello}: cli{hello}
diff --git a/examples/hello/driver.cxx b/examples/hello/driver.cxx
deleted file mode 100644
index 30fdf6e..0000000
--- a/examples/hello/driver.cxx
+++ /dev/null
@@ -1,58 +0,0 @@
-// file : examples/hello/driver.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// license : MIT; see accompanying LICENSE file
-
-#include <iostream>
-
-#include "hello.hxx"
-
-using namespace std;
-
-void
-usage (ostream& os)
-{
- os << "usage: driver [options] <names>" << endl
- << "options:" << endl;
- options::print_usage (os);
-}
-
-int
-main (int argc, char* argv[])
-{
- try
- {
- int end; // End of options.
- options o (argc, argv, end);
-
- if (o.help ())
- {
- usage (cout);
- return 0;
- }
-
- if (end == argc)
- {
- cerr << "no names provided" << endl;
- usage (cerr);
- return 1;
- }
-
- // Print the greetings.
- //
- for (int i = end; i < argc; i++)
- {
- cout << o.greeting () << ", " << argv[i];
-
- for (unsigned int j = 0; j < o.exclamations (); j++)
- cout << '!';
-
- cout << endl;
- }
- }
- catch (const cli::exception& e)
- {
- cerr << e << endl;
- usage (cerr);
- return 1;
- }
-}
diff --git a/examples/hello/hello.cli b/examples/hello/hello.cli
deleted file mode 100644
index b75e1b8..0000000
--- a/examples/hello/hello.cli
+++ /dev/null
@@ -1,18 +0,0 @@
-include <string>;
-
-class options
-{
- bool --help {"Print usage information and exit."};
-
- std::string --greeting = "Hello"
- {
- "<text>",
- "Use <text> as a greeting phrase instead of the default \"Hello\"."
- };
-
- unsigned int --exclamations = 1
- {
- "<num>",
- "Print <num> exclamation marks instead of 1 by default."
- };
-};