init: Enable subcommands for the main grass command #6442
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This enables access to the subcommands from the main grass command.
It keeps the commands not documented at the top level, so they remain hidden and experimental.
Backwards compatibility with the classic CLI parameters should be smooth. The decision is based on the first command line argument. This will yield unexpected results (only) when path to mapset matches one of the subcommands, e.g., when naming mapset simply mapset and running the grass command in the project directory which contains this mapset (same for project). It may become a bigger issue with more subcommands, but a simple workaround is prefixing the path
./
.This includes subcommands which are in other PRs, but the subcommand parser will deal with that by reporting an error. This could be an approach we take in general: reserving subcommand names even when we don't have them implemented yet (and triggering some of the directory (project, mapset, filename) issues sooner (even before a specific subcommand is fully introduced).
Before
python -m grass.app run --crs EPSG:3358 g.proj -p python -m grass.app mapset lock /path/to/mapset # mapset subcommand is in different PR
After
grass run --crs EPSG:3358 g.proj -p grass mapset unlock /path/to/mapset # mapset subcommand is in different PR
Commit message
This enables access to the subcommands from the main grass command.
It keeps the commands not documented at the top level, so they remain hidden and experimental.
Backwards compatibility with the classic CLI parameters should be smooth. The decision is based on the first command line argument. This will yield unexpected results (only) when path to mapset matches one of the subcommands, e.g., when naming mapset simply mapset and running the grass command in the project directory which contains this mapset (same for project). It may become a bigger issue with more subcommands, but a simple workaround is prefixing the path
./
.This includes subcommands which are in other PRs, but the subcommand parser will deal with that by reporting an error. This could be an approach we take in general: reserving subcommand names even when we don't have them implemented yet (and triggering some of the directory (project, mapset, filename) issues sooner (even before a specific subcommand is fully introduced).
This will is useful together with project create subcommand (#6441) and raster pack IO (#5877).
Before (assuming PYTHONPATH or FHS): python -m grass.app run --crs EPSG:3358 g.proj -p
After (assuming PATH): grass run --crs EPSG:3358 g.proj -p