[xsd-users] [ANN] CLI command line interface compiler for C++

Boris Kolpackov boris at codesynthesis.com
Thu Oct 29 04:30:02 EDT 2009


I would to announce a little side project of mine that some of you 
may find useful:

CLI is an open-source (MIT license), cross-platform command line 
interface compiler for C++. It allows you to specify the options that
your program supports, their types, and default values. For example:

include <string>;

class options
{
  bool --help;
  std::string --name = "example";
  unsigned int --level | -l = 5;
};

This specification can then be automatically translated to C++ classes 
that implement parsing of the command line arguments and provide a 
convenient and type-safe interface for accessing the extracted data.
For example:

#include <string>

class options
{
public:
  options (int argc, char** argv);
  options (int argc, char** argv, int& end);

  bool help () const;
  const std::string& name () const;
  unsigned int level () const;

  ...
};

int main (int argc, char* argv[])
{
  options o (argc, argv);

  if (o.help ())
    print_usage ();

  if (o.level () > 4)
    cerr << "name is " << o.name () << endl;
  ...
}

It is easy to start using CLI in your application since there are no 
external dependencies. You can compile your command line interface to 
C++ and simply add the generated files to your project's source code. 

For a five minute introduction to CLI, see the "Hello World" example in 
the CLI Getting Started Guide:

http://www.codesynthesis.com/projects/cli/doc/guide/#2

More information, documentation, and source code distributions are 
available from the project's web page:

http://www.codesynthesis.com/projects/cli/

Enjoy,
	Boris



More information about the xsd-users mailing list