Skip to content
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

Create a standardize format name for the shell script style (the g flag) #4492

Open
wenzeslaus opened this issue Oct 11, 2024 · 1 comment
Open
Labels
blocker Blocking a release enhancement New feature or request
Milestone

Comments

@wenzeslaus
Copy link
Member

Background

Recently, we were introducing JSON outputs and in the past, we already introduced the format parameter to tools like v.db.select. One question which remains is how the key-value format usually enabled by -g should be called? Documentation usually calls it something along the lines of "shell script style". The format is usually =-separated key-value pairs, one per line and unique keys (not always though). The original idea was that it can be put directly to Bash's eval function. This is the format typically parsed in the past by grass.script.parse_command to create a Python dictionary with keys and values provided by -g (side note: now that parses JSON as well but still defaults to expecting =-separated key-values).

Question

How the following flag should be replaced with a format option/parameter? Specifically, which value to use for the format option?

  -g   Print the stats in shell script style

Examples

This flag is, for example, found in r.univar and format option allows switching only between plain and json. -g right now acts as a modifier of the plain format. However, the idea is to present that as its own format which is likely more precise and fits with other tools with multiple formats. See these formats in v.db.select:

plain: Configurable plain text output
csv: CSV (Comma Separated Values)
json: JSON (JavaScript Object Notation)
vertical: Plain text vertical output (instead of horizontal)

r.univar has only:

plain: Plain text output
json: JSON (JavaScript Object Notation)

but should have something like:

plain: Plain text output
json: JSON (JavaScript Object Notation)
shell: Shell script style

Suggestions

Options:

shell: Shell script style
bash: Shell script style
bash: Bash-like script style
bash: Bash-like key-value pairs
bash: Key-value pairs in Bash-like syntax
eval: Values in Bash eval syntax
key-value: Key-value pairs in Bash-like syntax
keyval: Key-value pairs separated by equal sign

Feel free to add your suggestions or combinations of the above.

The description will be easy to change in the future, but the value is part of the API, so we need to set it and stick to it. Thus, the big decision is really between sh, shell, bash, script, eval, key-value, keyvalue, keyval, eqsep, ...

Implementation in v8 versus v9

In v8, we would add this to existing tools which now have format option and -g flag, for example r.univar. -g would stay there for compatibility. In v9, we can remove -g and only format would be used to change the output format. (This is similar to what happened with -v Vertical output (instead of horizontal) in v.db.select between v7 and v8.)

@wenzeslaus wenzeslaus added the enhancement New feature or request label Oct 11, 2024
@wenzeslaus wenzeslaus added this to the 8.5.0 milestone Oct 11, 2024
@wenzeslaus wenzeslaus added the blocker Blocking a release label Oct 14, 2024
@wenzeslaus
Copy link
Member Author

I'm putting this a blocker for the next major/minor release because it would be good to get it right for the release. (A backward compatible change in the future is possible, but it is avoidable if we decide soon.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Blocking a release enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant