]>
jfr.im git - irc/thales.git/blob - src/cmd.c
1 /* Command line parsing program of GNU Thales. Copyright (C)
2 2012 Free Software Foundation, Inc. This file is part of GNU Thales.
4 GNU Thales is free software; you can redistribute it and/or modify it under the
5 terms of the GNU General Public License as published by the Free Software
6 Foundation; either version 3 of the License, or (at your option) any later
9 GNU Make is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License along with
15 this program. If not, see <http://www.gnu.org/licenses/>. */
25 printf_option(const char *option
, const char *description
)
27 printf(" %-20s%-20s\n", option
, description
);
32 printf("Usage: thales [options]\n");
33 printf_option("--help, -h", "Display this information");
34 printf_option("--version, -v", "Display thales version");
35 printf_option("--debug, -d", "Enable output of debug information");
36 printf_option("--config, -C", "Override default configuration file");
43 puts("Copyright (C) 2012 Free Software Foundation, Inc.");
44 puts("This is free software; see the source for copying conditions. There is NO");
45 puts("warranty; not even for MERCHANTABILITY "
46 "or FITNESS FOR A PARTICULAR PURPOSE.");
50 parse_cmdopts(struct cmd_options
*opts
, int argc
, char **argv
)
53 const char *optstr
= "hvdC:";
54 struct option longopts
[] = {
55 {"help", no_argument
, NULL
, 'h'},
56 {"version", no_argument
, NULL
, 'v'},
57 {"config", required_argument
, NULL
, 'C'},
58 {"debug", no_argument
, &opts
->debug
, 'd'}
60 while ((val
= getopt_long(argc
, argv
, optstr
, longopts
, NULL
))!= EOF
)
70 opts
->conf_filename
= optarg
;