4
#include <grass/glocale.h>
6
#include "local_proto.h"
8
void parse_args(int argc, char **argv,
9
struct _options *options, struct _flags *flags)
11
options->dsn = G_define_option();
12
options->dsn->key = "output";
13
options->dsn->type = TYPE_STRING;
14
options->dsn->label = _("Name of output directory or OGR or PostGIS data source");
15
options->dsn->description = _("Examples:\n"
16
"\t\tESRI Shapefile: directory containing a shapefile\n"
17
"\t\tMapInfo File: directory containing a mapinfo file\n"
18
"\t\tPostGIS database: connection string, eg. 'PG:dbname=db user=grass'");
19
options->dsn->required = NO;
20
options->dsn->guisection = _("Settings");
22
options->format = G_define_option();
23
options->format->key = "format";
24
options->format->description = _("Format for output vector data");
25
options->format->required = NO;
26
options->format->type = TYPE_STRING;
27
options->format->options = format_options();
29
options->format->answer = "ESRI_Shapefile";
32
options->format->answer = "PostgreSQL";
33
#endif /* HAVE_POSTGRES */
35
options->format->guisection = _("Settings");
37
options->opts = G_define_option();
38
options->opts->key = "options";
39
options->opts->label = _("Creation options");
40
options->opts->description = _("Examples:\n"
41
"\t\t'SHPT=POINTZ': create 3D point Shapefile data\n"
42
"\t\t'GEOM_TYPE=geography': use geography PostGIS data\n"
43
"\t\t'SCHEMA=grass': create new PostGIS tables in 'grass' schema");
44
options->opts->required = NO;
45
options->opts->multiple = YES;
46
options->opts->type = TYPE_STRING;
47
options->opts->guisection = _("Settings");
49
options->input = G_define_standard_option(G_OPT_F_INPUT);
50
options->input->key = "loadsettings";
51
options->input->required = NO;
52
options->input->description = _("Name of input file to read settings from");
53
options->input->guisection = _("Settings");
55
options->output = G_define_standard_option(G_OPT_F_OUTPUT);
56
options->output->key = "savesettings";
57
options->output->required = NO;
58
options->output->description = _("Name for output file where to save current settings");
60
flags->f = G_define_flag();
62
flags->f->description = _("List supported formats and exit");
63
flags->f->guisection = _("Print");
64
flags->f->suppress_required = YES;
66
flags->r = G_define_flag();
68
flags->r->description = _("Cease using OGR/PostGIS, revert to native output and exit");
69
flags->r->suppress_required = YES;
70
flags->r->guisection = _("Native");
72
flags->p = G_define_flag();
74
flags->p->description = _("Print current status");
75
flags->p->guisection = _("Print");
76
flags->p->suppress_required = YES;
78
flags->g = G_define_flag();
80
flags->g->description = _("Print current status in shell script style");
81
flags->g->guisection = _("Print");
82
flags->g->suppress_required = YES;
84
if (G_parser(argc, argv))
88
if (options->dsn->answer && options->format->answer &&
89
options->input->answer)
90
G_fatal_error(_("%s= and %s=/%s= are mutually exclusive"),
92
options->dsn->key, options->format->key);
93
if (flags->f->answer || flags->p->answer || flags->r->answer || flags->g->answer ||
94
options->output->answer)
97
if (!options->dsn->answer && !options->input->answer)
98
G_fatal_error(_("%s= or %s= must be specified"),
99
options->dsn->key, options->input->key);
100
if (options->dsn->answer && !options->format->answer)
101
G_fatal_error(_("%s= must be specified"),
102
options->format->key);