|
0
|
1 |
// Copyright (C) 1999,2000 Bruce Guenter <bruceg@em.ca>
|
|
|
2 |
//
|
|
|
3 |
// This program is free software; you can redistribute it and/or modify
|
|
|
4 |
// it under the terms of the GNU General Public License as published by
|
|
|
5 |
// the Free Software Foundation; either version 2 of the License, or
|
|
|
6 |
// (at your option) any later version.
|
|
|
7 |
//
|
|
|
8 |
// This program is distributed in the hope that it will be useful,
|
|
|
9 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
10 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
11 |
// GNU General Public License for more details.
|
|
|
12 |
//
|
|
|
13 |
// You should have received a copy of the GNU General Public License
|
|
|
14 |
// along with this program; if not, write to the Free Software
|
|
|
15 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
16 |
|
|
|
17 |
#include <config.h>
|
|
|
18 |
#include "cli.h"
|
|
|
19 |
#include "fdbuf/fdbuf.h"
|
|
|
20 |
|
|
|
21 |
const char* cli_program = "clitest";
|
|
|
22 |
const char* cli_help_prefix = "Does nothing but set flags\n";
|
|
|
23 |
const char* cli_help_suffix = "";
|
|
|
24 |
const char* cli_args_usage = "";
|
|
|
25 |
const int cli_args_min = 0;
|
|
|
26 |
const int cli_args_max = -1;
|
|
|
27 |
int o_flag = 0;
|
|
|
28 |
int o_int = 0;
|
|
|
29 |
char* o_string = "nostring";
|
|
|
30 |
cli_option cli_options[] = {
|
|
|
31 |
{ 'f', "flag", cli_option::flag, 1, &o_flag, "Sets a flag", 0 },
|
|
|
32 |
{ 'i', "int", cli_option::integer, 0, &o_int, "Sets an integer", 0 },
|
|
|
33 |
{ 's', "str", cli_option::string, 0, &o_string, "Sets a string", 0},
|
|
|
34 |
{0} };
|
|
|
35 |
|
|
|
36 |
int cli_main(int argc, char* argv[])
|
|
|
37 |
{
|
|
|
38 |
fout << "argv0=" << argv0 << endl
|
|
|
39 |
<< " argv0dir=" << argv0dir << endl
|
|
|
40 |
<< " argv0base=" << argv0base << endl;
|
|
|
41 |
fout << "The flag is set to " << o_flag << endl;
|
|
|
42 |
fout << "The integer is set to " << o_int << endl;
|
|
|
43 |
fout << "The string is set to " << o_string << endl;
|
|
|
44 |
for(int i = 0; i < argc; i++)
|
|
|
45 |
fout << "argv[" << i << "] = '" << argv[i] << "'\n";
|
|
|
46 |
return 0;
|
|
|
47 |
}
|