Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#3585 closed enhancement (fixed)

Don't require -c for --tmp-location

Reported by: wenzeslaus Owned by: grass-dev@…
Priority: normal Milestone: 8.0.0
Component: Startup Version: svn-trunk
Keywords: init, grass.py, location, tmp-location, CRS, CLI, gsoc2018 Cc:
CPU: Unspecified Platform: Unspecified

Description

With this ticket, I'm seeking feedback for designing interface for creating temporary locations from command line.

With --tmp-location (#3537, r72790), CRS needs to be specified using the -c flag:

grass7 -c EPSG:3358 --tmp-location --exec g.proj -p

Without --tmp-location, -c is used to tell GRASS to create a new location or mapset. However, with --tmp-location GRASS knows that it needs to create a new location, so -c is required here to only specify the coordinate system. Thus, --tmp-location could itself require a value to be provided, so that the syntax would become:

grass7 --tmp-location EPSG:3358 --exec g.proj -p

Usage would look like (new):

grass75 --tmp-location [geofile | EPSG] --exec EXECUTABLE [EPARAM]...

Instead of (old):

grass75 -c [geofile | EPSG] --tmp-location --exec EXECUTABLE [EPARAM]...

Or concisely with a reference:

  grass75 [-h | -help | --help | --h] [-v | --version]
          [-c [CRS]] [-e] [-f]
          [-text | -gtext | -gui] [--config param]
          [[[GISDBASE/]LOCATION_NAME/]MAPSET]
  grass75 [FLAG]... GISDBASE/LOCATION_NAME/MAPSET --exec EXECUTABLE [EPARAM]...
  grass75 --tmp-location CPARAM --exec EXECUTABLE [EPARAM]...
  ...
  CRS                            nothing or geofile or EPSG:code[:datum_trans] 
  CRS (or written like:)         [geofile | EPSG:code[:datum_trans]]
  EXECUTABLE                     GRASS module, script or any other executable
  EPARAM                         parameters of the executable
  FLAG                           standard flags
# Alternatives to CRS are SRS and CPARAM (like EPARAM).

Note 1: The current parsing does not care about order, so e.g. grass7 --tmp-location EPSG:3358 -c --exec... is possible now. This should be probably fixed in the future (e.g. 8.0.0 release). (It is not specified in the manual, so the current behavior can fixed/dropped any time.)

Note 2: This is part of making the command line as short as possible, so it might be strange that the --tmp-location flag is long, but that's a topic for another ticket.

Change History (5)

comment:1 by mlennert, 6 years ago

No objections from my side, only one question: what is the logic concerning - vs -- parameters ?

comment:2 by wenzeslaus, 6 years ago

Many of them are legacy. -text is not really a good practice, -t and/or --text are better. See also: wiki:Grass8Planning#grassexecutable. The newer ones like --config are with two dashes which are also supported (but undocumented) for all other "long" flags.

comment:3 by neteler, 6 years ago

Short feedback: I've started to use --tmp-location, it works nicely!

Version 0, edited 6 years ago by neteler (next)

comment:4 by wenzeslaus, 6 years ago

Resolution: fixed
Status: newclosed

In 73096:

init: -c not needed for --tmp-location (closes #3585)

--tmp-location required -c flag because -c was associated with EPSG specification.
The new approach is that EPSG is a value of whatever flag/option which needs
EPSG or equivalent.

No changes in the code. Parsing just takes any ARG (non-flag) available.
We check if EPSG was provided and that mapset was not provided (i.e. exactly
one ARG was provided). It is no longer possible to use --tmp-location without
ARG to create an XY location.

comment:5 by wenzeslaus, 6 years ago

In 73099:

init: update doc for --tmp-location without -c (finishes r73096, see #3585)

Note: See TracTickets for help on using tickets.