source: trunk/test/commandline_test.cc @ 603

Last change on this file since 603 was 603, checked in by Peter, 15 years ago

set properties

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 999 bytes
Line 
1// $Id: commandline_test.cc 603 2006-08-29 04:23:04Z peter $
2
3#include <c++_tools/utility/CommandLine.h>
4#include <c++_tools/utility/Option.h>
5
6#include <iostream>
7
8using namespace theplu;
9
10int main(const int argc,const char* argv[])
11{
12  bool ok = true;
13
14  utility::CommandLine cmd;
15  cmd.set_general_description("test program for CommandLine class");
16  cmd.add_parameter('n', utility::Option::int_arg, 
17                    "example of parameter taking an integer");
18  cmd.add_parameter('v',utility::Option::no_arg, "explain what is being done");
19  cmd.add_parameter('t', "target", utility::Option::string_arg);
20  cmd.add_parameter("version",utility::Option::no_arg, 
21                    "output version infomation and exit");
22  cmd.set_help();
23  cmd.parse(argc, argv);
24  std::string target = cmd.value("target");
25  if (!target.empty())
26    std::cout << "target: " << target << std::endl;
27  int n = cmd.value_int("n");
28  if (cmd.present("n"))
29    std::cout << "n: " << n << std::endl;
30  if (cmd.present("v"))
31    std::cout << "verbose" << std::endl;
32
33  if (ok) {
34    return 0;
35  }
36  return -1;
37
38}
Note: See TracBrowser for help on using the repository browser.