args.c 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include <stdlib.h>
  2. #include <grass/gis.h>
  3. #include <grass/glocale.h>
  4. #include "local_proto.h"
  5. void parse_args(int argc, char **argv,
  6. struct _options *options, struct _flags* flags)
  7. {
  8. options->dsn = G_define_option();
  9. options->dsn->key = "input";
  10. options->dsn->type = TYPE_STRING;
  11. options->dsn->label = _("Name of input OGR or PostGIS data source");
  12. options->dsn->description = _("Examples:\n"
  13. "\t\tESRI Shapefile: directory containing a shapefile\n"
  14. "\t\tMapInfo File: directory containing a mapinfo file\n"
  15. "\t\tPostGIS database: connection string, eg. 'PG:dbname=db user=grass'");
  16. options->dsn->required = YES;
  17. options->dsn->gisprompt = "old,datasource,datasource";
  18. options->layer = G_define_option();
  19. options->layer->key = "layer";
  20. options->layer->type = TYPE_STRING;
  21. options->layer->required = NO;
  22. options->layer->multiple = NO;
  23. options->layer->label = _("Name of OGR layer or PostGIS feature table to be linked");
  24. options->layer->description = _("Examples:\n"
  25. "\t\tESRI Shapefile: shapefile name\n"
  26. "\t\tMapInfo File: mapinfo file name\n"
  27. "\t\tPostGIS database: table name");
  28. options->layer->required = NO;
  29. options->layer->key_desc = "name";
  30. options->layer->gisprompt = "old,datasource_layer,datasource_layer";
  31. options->where = G_define_standard_option(G_OPT_DB_WHERE);
  32. options->output = G_define_standard_option(G_OPT_V_OUTPUT);
  33. options->output->required = NO;
  34. options->output->description = _("Name for output GRASS vector map (default: input layer)");
  35. flags->override = G_define_flag();
  36. flags->override->key = 'o';
  37. flags->override->label =
  38. _("Override projection check (use current location's projection)");
  39. flags->override->description =
  40. _("Assume that the dataset has the same projection as the current location");
  41. flags->proj = G_define_flag();
  42. flags->proj->key = 'j';
  43. flags->proj->description =
  44. _("Perform projection check only and exit");
  45. flags->format = G_define_flag();
  46. flags->format->key = 'f';
  47. flags->format->description = _("List supported formats and exit");
  48. flags->format->guisection = _("Print");
  49. flags->format->suppress_required = YES;
  50. flags->list = G_define_flag();
  51. flags->list->key = 'l';
  52. flags->list->description = _("List available layers in data source and exit");
  53. flags->list->guisection = _("Print");
  54. flags->list->suppress_required = YES;
  55. flags->tlist = G_define_flag();
  56. flags->tlist->key = 't';
  57. flags->tlist->label = _("List available layers including feature type "
  58. "in data source and exit");
  59. flags->tlist->description = _("Format: layer name,type,projection check,geometry");
  60. flags->tlist->guisection = _("Print");
  61. flags->tlist->suppress_required = YES;
  62. flags->topo = G_define_standard_flag(G_FLG_V_TOPO);
  63. if (G_parser(argc, argv))
  64. exit(EXIT_FAILURE);
  65. }