[GRASS-git] [OSGeo/grass] aeff9f: init: Use argparse instead of custom parsing for C...

Vaclav Petras noreply at github.com
Tue Jan 12 19:02:01 PST 2021


  Branch: refs/heads/master
  Home:   https://github.com/OSGeo/grass
  Commit: aeff9f46465154bac239227dc3fc1f2247d24100
      https://github.com/OSGeo/grass/commit/aeff9f46465154bac239227dc3fc1f2247d24100
  Author: Vaclav Petras <wenzeslaus at gmail.com>
  Date:   2021-01-12 (Tue, 12 Jan 2021)

  Changed paths:
    M lib/init/grass.py

  Log Message:
  -----------
  init: Use argparse instead of custom parsing for CLI (#1239)

Using argparse will makes the command line parsing code easier to maintain. Additionally, this PR makes the code ready for bigger CLI changes.

Tries to preserve behavior of all options including `--config` and `--exec`.

Uses the old help message, although the argparse one is quite usable using it would further ease the maintenance.
User still recieves the argparse one with more options or arguments and help, e.g., with `xxx yyy --help`.

The `-c` (create mapset or location) option needs a special handling outside of argparse, because in `-c mapset/path` the `mapset/path` piece is interpreted as value of `-c` rather than a separate argument. Note that this shows more a non-standard design of the current command line parameters rather than a flaw in argparse: `-c [CRS] [PATH]` is ambiguous for `-c xyz`.

Removes the batch job environmental variable (`GRASS_BATCH_JOB`). It required separate handling and `--exec` is more powerful and common interface.

There is no _Hit RETURN to continue_ in messages. The execution now simply continues instead of asking a user,
who just did not get a hoped-for GUI, to find and slam something called RETURN
(modern keyboards often don't have a Really-Ennoyed-Troubled-User-Running-Nuts key
and suggesting users to hit other objects to vent their frustration with a broken
GUI could make us liable).

Some things which were originally warnings in mapset and location creation process are now fatal errors.
Error messages related to GUI are now simpler, shorter in general, so hopefully easier
to spot and read. Mentioning also the installation besides `GRASS_PYTHON` var.




More information about the grass-commit mailing list