diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-09-27 19:18:32 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-09-27 19:18:32 +0200 |
commit | cede34ad1ac6730f5f2c88b4dd655f90589ae803 (patch) | |
tree | 37a35f45833fc4ffb71f643c07d8828b9b329e01 /examples/hello/driver.cxx | |
parent | c2b7e8a5a7bc98bcf5e03b32eefaa664442c26fe (diff) |
Add a hello world example
Diffstat (limited to 'examples/hello/driver.cxx')
-rw-r--r-- | examples/hello/driver.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/examples/hello/driver.cxx b/examples/hello/driver.cxx new file mode 100644 index 0000000..c211601 --- /dev/null +++ b/examples/hello/driver.cxx @@ -0,0 +1,41 @@ +// file : examples/hello/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#include <iostream> + +#include "hello.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + try + { + int end; // End of options. + options o (argc, argv, end); + + if (o.help ()) + { + cerr << "hello v. 1.0.0" << endl; + return 0; + } + + 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; + return 1; + } +} |