grass icon indicating copy to clipboard operation
grass copied to clipboard

[Feat] g.region: implement standalone flat flag in g.region

Open echoix opened this issue 6 months ago • 1 comments

Flag -f of g.region should be standalone. Now it needs to be used together with -g flag. Standalone behavior aligns with the current description of the flag:

Print in shell script style, but in one line (flat)

In terms of backwards compatibility, there shouldn't be any problem, because -gf should still work.

I tested the standalone -f flag, here is the code for it, but probably you are right this should be a separate PR.

diff --git a/general/g.region/main.c b/general/g.region/main.c
index 06c33a2e8c..33ad06f383 100644
--- a/general/g.region/main.c
+++ b/general/g.region/main.c
@@ -361,7 +361,7 @@ int main(int argc, char *argv[])
     G_option_required(
         flag.dflt, flag.savedefault, flag.print, flag.lprint, flag.eprint,
         flag.center, flag.gmt_style, flag.wms_style, flag.dist_res, flag.nangle,
-        flag.z, flag.bbox, flag.gprint, flag.res_set, flag.noupdate,
+        flag.z, flag.bbox, flag.gprint, flag.flprint, flag.res_set, flag.noupdate,
         parm.region, parm.raster, parm.raster3d, parm.vect, parm.north,
         parm.south, parm.east, parm.west, parm.top, parm.bottom, parm.rows,
         parm.cols, parm.res, parm.res3, parm.nsres, parm.ewres, parm.tbres,
@@ -371,7 +371,6 @@ int main(int argc, char *argv[])
                       flag.eprint, flag.center, flag.gmt_style, flag.wms_style,
                       flag.dist_res, flag.nangle, flag.z, flag.bbox,
                       flag.gprint, parm.save, NULL);
-    G_option_requires(flag.flprint, flag.gprint, NULL);
 
     if (G_parser(argc, argv))
         exit(EXIT_FAILURE);
@@ -383,7 +382,7 @@ int main(int argc, char *argv[])
     if (flag.print->answer)
         print_flag |= PRINT_REG;
 
-    if (flag.gprint->answer)
+    if (flag.gprint->answer || flat_flag)
         print_flag |= PRINT_SH;
 
     if (flag.lprint->answer)

Originally posted by @petrasovaa in https://github.com/OSGeo/grass/pull/3216#pullrequestreview-1854428326

echoix avatar Feb 08 '24 05:02 echoix