From a15cf65c44d5c224169c32ef5495b68c758134b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 18 May 2014 16:08:14 +0200 Subject: Imported Upstream version 3.3.0.2 --- libcult/examples/cli/cli.cxx | 65 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 libcult/examples/cli/cli.cxx (limited to 'libcult/examples/cli/cli.cxx') diff --git a/libcult/examples/cli/cli.cxx b/libcult/examples/cli/cli.cxx new file mode 100644 index 0000000..922a23d --- /dev/null +++ b/libcult/examples/cli/cli.cxx @@ -0,0 +1,65 @@ +// file : examples/cli/cli.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include +#include +#include + +#include + +using std::cerr; +using std::endl; + +using namespace Cult; + +namespace +{ + extern Char const help[] = "help"; + extern Char const version[] = "version"; + extern Char const outdir[] = "outdir"; +} + +typedef +CLI::Options +Options; + +Int +main (Int argc, Char* argv[]) +{ + try + { + Options options (CLI::parse (argc, argv)); + + if (options.value ()) + { + cerr << "usage: " << argv[0] << " [--help] [--version] [--outdir ]" + << endl; + return 0; + } + + if (options.value ()) + { + cerr << argv[0] << " 1.2.3" << endl; + return 0; + } + + if (String dir = options.value ()) + { + cerr << "outdir: " << dir << endl; + } + } + catch (CLI::UnexpectedOption const& e) + { + cerr << "unexpected option " << e.option () <