[GRASS-git] [OSGeo/grass] 21e8eb: grass.script: Allow a leading dash in flags parame...

Vaclav Petras noreply at github.com
Tue Jun 24 06:25:30 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: 21e8ebbaa01f5a2e858e033d7b6ae139ff41e201
      https://github.com/OSGeo/grass/commit/21e8ebbaa01f5a2e858e033d7b6ae139ff41e201
  Author: Vaclav Petras <wenzeslaus at gmail.com>
  Date:   2025-06-24 (Tue, 24 Jun 2025)

  Changed paths:
    M python/grass/script/core.py
    A python/grass/script/tests/grass_script_run_command_test.py

  Log Message:
  -----------
  grass.script: Allow a leading dash in flags parameter (#5952)

Instead of raising a ScriptError, accept a leading dash for the flags parameter in run_command family of functions. While no dash is the best practice in Python, and therefore no examples or documentation are changed, leading dash is required in the command line and appears in documentation and messages, so allowing it in Python makes it little easier on the user.

In command line, leading dash is required for a group a flag letters which would be the most typical use of multiple flags. Since this requirement is not going away - it is part of the command line syntax itself, we ease the transition between the two environments by supporting the leading dash in Python. Dashes inside the flags string, including space-separated flag characters with dashes, are not supported because that would basically mean processing the space separated command line syntax (trivial to process in this case, but does go too far from Python list of flag letters into full command line syntax). Even with a leading dash, the code looks sufficiently like Python.

In documentation and messages (typically warnings or errors), we use mix of standalone character (possibly in single or double quotes) and a dash followed by a character. While it may be worth polishing this across the documentation and code, and perhaps going with characters only (because they apply in both command line and Python), the command line examples will always have dashes, so supporting the dash for copy-pasting scenarios would be nice. (The new generated Python documentation for tools does not include the dashes, so it supports more doing the right thing - characters only, but command line examples are currently prevalent and will always be preset.)



To unsubscribe from these emails, change your notification settings at https://github.com/OSGeo/grass/settings/notifications


More information about the grass-commit mailing list