[GRASS-dev] [GRASS GIS] #3585: Don't require -c for --tmp-location

#3585: Don't require -c for --tmp-location
-------------------------------------------------+-------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
     Type: enhancement | Status: new
Priority: normal | Milestone: 8.0.0
Component: Startup | Version: svn-trunk
Keywords: init, grass.py, location, tmp- | CPU: Unspecified
  location, CRS, CLI, gsoc2018 |
Platform: Unspecified |
-------------------------------------------------+-------------------------
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.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3585&gt;
GRASS GIS <https://grass.osgeo.org>

#3585: Don't require -c for --tmp-location
-------------------------+-------------------------------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: | Status: new
  enhancement |
  Priority: normal | Milestone: 8.0.0
Component: Startup | Version: svn-trunk
Resolution: | Keywords: init, grass.py, location, tmp-
       CPU: | location, CRS, CLI, gsoc2018
  Unspecified | Platform: Unspecified
-------------------------+-------------------------------------------------

Comment (by mlennert):

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

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3585#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#3585: Don't require -c for --tmp-location
-------------------------+-------------------------------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: | Status: new
  enhancement |
  Priority: normal | Milestone: 8.0.0
Component: Startup | Version: svn-trunk
Resolution: | Keywords: init, grass.py, location, tmp-
       CPU: | location, CRS, CLI, gsoc2018
  Unspecified | Platform: Unspecified
-------------------------+-------------------------------------------------

Comment (by wenzeslaus):

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.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3585#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#3585: Don't require -c for --tmp-location
-------------------------+-------------------------------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: | Status: new
  enhancement |
  Priority: normal | Milestone: 8.0.0
Component: Startup | Version: svn-trunk
Resolution: | Keywords: init, grass.py, location, tmp-
       CPU: | location, CRS, CLI, gsoc2018
  Unspecified | Platform: Unspecified
-------------------------+-------------------------------------------------

Comment (by neteler):

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

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3585#comment:3&gt;
GRASS GIS <https://grass.osgeo.org>

#3585: Don't require -c for --tmp-location
-------------------------+-------------------------------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: | Status: closed
  enhancement |
  Priority: normal | Milestone: 8.0.0
Component: Startup | Version: svn-trunk
Resolution: fixed | Keywords: init, grass.py, location, tmp-
       CPU: | location, CRS, CLI, gsoc2018
  Unspecified | Platform: Unspecified
-------------------------+-------------------------------------------------
Changes (by wenzeslaus):

* status: new => closed
* resolution: => fixed

Comment:

In [changeset:"73096" 73096]:
{{{
#!CommitTicketReference repository="" revision="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.
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3585#comment:4&gt;
GRASS GIS <https://grass.osgeo.org>

#3585: Don't require -c for --tmp-location
-------------------------+-------------------------------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: | Status: closed
  enhancement |
  Priority: normal | Milestone: 8.0.0
Component: Startup | Version: svn-trunk
Resolution: fixed | Keywords: init, grass.py, location, tmp-
       CPU: | location, CRS, CLI, gsoc2018
  Unspecified | Platform: Unspecified
-------------------------+-------------------------------------------------

Comment (by wenzeslaus):

In [changeset:"73099" 73099]:
{{{
#!CommitTicketReference repository="" revision="73099"
init: update doc for --tmp-location without -c (finishes r73096, see
#3585)
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3585#comment:5&gt;
GRASS GIS <https://grass.osgeo.org>