~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to vector/v.external.out/args.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdlib.h>
 
2
 
 
3
#include <grass/gis.h>
 
4
#include <grass/glocale.h>
 
5
 
 
6
#include "local_proto.h"
 
7
 
 
8
void parse_args(int argc, char **argv,
 
9
                struct _options *options, struct _flags *flags)
 
10
{
 
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");
 
21
 
 
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();
 
28
#ifdef HAVE_OGR
 
29
    options->format->answer = "ESRI_Shapefile";
 
30
#else
 
31
#ifdef HAVE_POSTGRES
 
32
    options->format->answer = "PostgreSQL";
 
33
#endif /* HAVE_POSTGRES */
 
34
#endif /* HAVE_OGR */
 
35
    options->format->guisection = _("Settings");
 
36
 
 
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");
 
48
 
 
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");
 
54
 
 
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");
 
59
 
 
60
    flags->f = G_define_flag();
 
61
    flags->f->key = 'f';
 
62
    flags->f->description = _("List supported formats and exit");
 
63
    flags->f->guisection = _("Print");
 
64
    flags->f->suppress_required = YES;
 
65
 
 
66
    flags->r = G_define_flag();
 
67
    flags->r->key = 'r';
 
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");
 
71
    
 
72
    flags->p = G_define_flag();
 
73
    flags->p->key = 'p';
 
74
    flags->p->description = _("Print current status");
 
75
    flags->p->guisection = _("Print");
 
76
    flags->p->suppress_required = YES;
 
77
 
 
78
    flags->g = G_define_flag();
 
79
    flags->g->key = 'g';
 
80
    flags->g->description = _("Print current status in shell script style");
 
81
    flags->g->guisection = _("Print");
 
82
    flags->g->suppress_required = YES;
 
83
 
 
84
    if (G_parser(argc, argv))
 
85
        exit(EXIT_FAILURE);
 
86
 
 
87
    /* check options */
 
88
    if (options->dsn->answer && options->format->answer &&
 
89
        options->input->answer)
 
90
        G_fatal_error(_("%s= and %s=/%s= are mutually exclusive"),
 
91
                      options->input->key,
 
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)
 
95
        return;
 
96
 
 
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);
 
103
}