.SH SYNOPSIS
.B empdump
[
-.B \-mtxhv
+.B \-mnxhv
]
[
.BI \-e " configfile"
]
[
-.I dump-file
+.BI \-i " dump-file"
]
.br
.SH DESCRIPTION
.B \-h
Help. Print brief usage information and exit.
.TP
+.BI \-i " dump-file"
+Import from \fIdump-file\fR.
.TP
.B \-m
Use machine-readable format for export. Import always recognizes both
machine-readable and human-readable format.
.TP
-.B \-t
-Test import, don't update game state.
+.B \-n
+Dry run, don't actually update game state on import.
.TP
.B \-v
Print version information and exit.
.TP
.B \-x
Export game state to standard output.
-.SH OPERANDS
-.TP
-.I dump-file
-The file to import.
.SH "LIMITATIONS"
.B empdump
can't export player bmaps, power report, telegrams, announcements,
#include "version.h"
#include "xdump.h"
+static void exit_bad_arg(char *, ...) ATTRIBUTE((noreturn));
static void dump_table(int, int);
static void pln_fixup(void);
static void lnd_fixup(void);
FILE *impf = NULL;
int dirty[EF_MAX];
- while ((opt = getopt(argc, argv, "e:mtxhv")) != EOF) {
+ while ((opt = getopt(argc, argv, "e:i:mnxhv")) != EOF) {
switch (opt) {
case 'e':
config_file = optarg;
break;
+ case 'i':
+ import = optarg;
+ break;
+ case 'm':
+ human = 0;
+ break;
+ case 'n':
+ private = EFF_PRIVATE;
+ break;
+ case 'x':
+ export = 1;
+ break;
case 'h':
- printf("Usage: %s [OPTION]... [DUMP-FILE]\n"
+ printf("Usage: %s [OPTION]...\n"
" -e CONFIG-FILE configuration file\n"
" (default %s)\n"
+ " -i DUMP-FILE import from DUMP-FILE\n"
" -m use machine-readable format\n"
- " -t test import, don't update game state\n"
+ " -n dry run, don't update game state\n"
" -x export to standard output\n"
" -h display this help and exit\n"
" -v display version information and exit\n",
argv[0], dflt_econfig);
exit(0);
- case 'm':
- human = 0;
- break;
- case 't':
- private = EFF_PRIVATE;
- break;
- case 'x':
- export = 1;
- break;
case 'v':
printf("%s\n\n%s", version, legal);
exit(0);
default:
- fprintf(stderr, "Try -h for help.\n");
- exit(1);
+ exit_bad_arg(NULL);
}
}
if (argv[optind])
- import = argv[optind++];
+ exit_bad_arg("%s: extra operand %s\n", argv[0], argv[optind]);
+
+ if (!import && !export)
+ exit_bad_arg("%s: nothing to do!\n", argv[0]);
if (import) {
impf = fopen(import, "r");
return 0;
}
+static void
+exit_bad_arg(char *complaint, ...)
+{
+ va_list ap;
+
+ if (complaint) {
+ va_start(ap, complaint);
+ vfprintf(stderr, complaint, ap);
+ va_end(ap);
+ }
+ fprintf(stderr, "Try -h for help.\n");
+ exit(1);
+}
+
static void
printf_wrapper(char *fmt, ...)
{