(main, print_usage): New options -h and -v.
(print_usage): Improve usage message.
This commit is contained in:
parent
68a7ae71b0
commit
1af78f75ef
1 changed files with 16 additions and 4 deletions
|
@ -61,6 +61,7 @@
|
||||||
#include "tel.h"
|
#include "tel.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
static void file_sct_init(coord x, coord y, s_char *ptr,
|
static void file_sct_init(coord x, coord y, s_char *ptr,
|
||||||
time_t timestamp);
|
time_t timestamp);
|
||||||
|
@ -68,8 +69,13 @@ static void file_sct_init(coord x, coord y, s_char *ptr,
|
||||||
static void
|
static void
|
||||||
print_usage(char *program_name)
|
print_usage(char *program_name)
|
||||||
{
|
{
|
||||||
printf("Usage: %s -f -e econfig_file\n", program_name);
|
printf("Usage: %s [OPTION]...\n"
|
||||||
printf("-f force mode\n");
|
" -e CONFIG-FILE configuration file\n"
|
||||||
|
" (default %s)\n"
|
||||||
|
" -f force overwrite of existing game\n"
|
||||||
|
" -h display this help and exit\n"
|
||||||
|
" -v display version information and exit\n",
|
||||||
|
program_name, dflt_econfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -88,7 +94,7 @@ main(int argc, char *argv[])
|
||||||
int force = 0;
|
int force = 0;
|
||||||
time_t current_time = time(NULL);
|
time_t current_time = time(NULL);
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "e:f")) != EOF) {
|
while ((opt = getopt(argc, argv, "e:fhv")) != EOF) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'e':
|
case 'e':
|
||||||
config_file = optarg;
|
config_file = optarg;
|
||||||
|
@ -96,9 +102,15 @@ main(int argc, char *argv[])
|
||||||
case 'f':
|
case 'f':
|
||||||
force = 1;
|
force = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
print_usage(argv[0]);
|
||||||
|
exit(0);
|
||||||
|
case 'v':
|
||||||
|
printf("%s\n\n%s", version, legal);
|
||||||
|
exit(0);
|
||||||
default:
|
default:
|
||||||
print_usage(argv[0]);
|
print_usage(argv[0]);
|
||||||
exit(-1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue