-
-
Notifications
You must be signed in to change notification settings - Fork 391
g.parser: Extend --json flag and documentation #6697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
There is also super quiet. |
Right, but superquiet cannot be invoked from the CLI, or can it? The man / CLI documents only verbose and quiet. And the CLI is what the JSON output of the parser should reflect, no? It is invoked by actinia at the end anyway... |
|
See the new 8.5 doc. It should be there. Also, in the past, it was broken in the run_command function, but that's fixed now. |
|
Hm... I have tried to figure out how to detect superquiet mode, but did not manage without changing the parser handling of --qq. Lines 573 to 587 in d3c6479
G_Verbose_min() returns 0 as MINLEVEL also with --qq.
I tried setting GRASS_VERBOSE to -1 if the |
|
The detection must be somewhere in G_warning because it disables warnings. |
G_warning receives an extra parameter to not print a warning. So, that does not seem to work here. I added superquiet to the state struct in the parser, similar to quiet, verbose, and overwrite. Hope that is an acceptable solution? |
wenzeslaus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going in the right direction. I see issue with initialization. I investigated a little bit in parser.c and error.c, but did not come to any specific conclusion. You need to check how st is initialized and make sure all the variables (attributes of st) you are using initialized. It seems to me that even the quiet and verbose are potentially wrong. If you already went through this, just let me know what you find out.
|
|
||
| Many GRASS modules produce textual output to stdout and actinia allows | ||
| to export that output as well, however, the **--json** flag does not yet | ||
| allow to specify export of stdout which may look in an actinia processing | ||
| chain e.g. like this: | ||
|
|
||
| ```json | ||
| { | ||
| ... | ||
| 'stdout': {'id': 'stats', 'format': 'kv', 'delimiter': '='}, | ||
| } | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not clear. What a user is supposed to do here? I'm missing something like "So, to do X, do A, B and C."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the updated text...
lib/gis/parser.c
Outdated
| "both. Assuming --verbose.")); | ||
| } | ||
| st->quiet = -1; | ||
| st->superquiet = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is suspicions as it is not initialized anywhere.
lib/gis/parser.c
Outdated
| G_warning(_("Use either --qq or --verbose flag, not " | ||
| "both. Assuming --verbose.")); | ||
| } | ||
| st->superquiet = 0; /* for passing to gui init */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably set a bool to either true or false for future compatibility (see https://en.cppreference.com/w/c/language/bool_constant.html).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 7197c4a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For real bool value (as in the case with the change to bool superquiet;) lowercase true and false should be used. Uppercase variants are macros defined in:
Lines 74 to 83 in dd421a0
| /* For boolean values and comparisons use the C99 type 'bool' with values 'true' | |
| */ | |
| /* and 'false' For historical reasons 'TRUE' and 'FALSE' are still valid. */ | |
| #ifndef TRUE | |
| #define TRUE 1 | |
| #endif | |
| #ifndef FALSE | |
| #define FALSE 0 | |
| #endif |
and are used in int-based boolean functionality, e.g.:
grass/include/grass/defs/gis.h
Line 315 in dd421a0
| int G_suppress_warnings(int); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to lowercase for superquiet.
lib/gis/parser.c
Outdated
|
|
||
| /* print everything: max verbosity level */ | ||
| st->module_info.verbose = G_verbose_max(); | ||
| snprintf(buff, sizeof(buff), "GRASS_VERBOSE=%d", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With G_set_verbose() added, may this snprintf + putenv blocks be removed?
When i ran some local tests, it does not seem to have any effect after the first time such a block had run, e.g. if users provide both --v and --pp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With G_set_verbose() added, may this snprintf + putenv blocks be removed?
I believe it can, G_set_verbose() is the dedicated API for just this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the snprintf + putenv blocks.
This PR adds support for extended flags (--overwrite, --verbose, --quiet) to the --json flag and extends the documentation of available functionality in --json.
Replaces #2937