Open T1t4m1un opened 7 months ago
@T1t4m1un thanks for the contribution, but I don't like the idea of using printf
to print directly to the output.
I agree that the output format is quite simple, but the aim should be to have much more information in the JSON output, so the list
array with the count
and users
subelements, the command name, version and all the other stuff we have for pgagroal-cli
json output. In other words, please use the json.c
stuff.
The aim is not to present output in brackets, it is to allow for automation, hence the output must be as complete as possible.
@T1t4m1un thanks for the contribution, but I don't like the idea of using
printf
to print directly to the output. I agree that the output format is quite simple, but the aim should be to have much more information in the JSON output, so thelist
array with thecount
andusers
subelements, the command name, version and all the other stuff we have forpgagroal-cli
json output. In other words, please use thejson.c
stuff.
OK, I will refactor it~
The aim is not to present output in brackets, it is to allow for automation, hence the output must be as complete as possible.
Could you give me some examples of the format? I don't clearly understand the format you envisioned😶🌫️
Could you give me some examples of the format? I don't clearly understand the format you envisioned😶🌫️
See https://github.com/agroal/pgagroal/blob/master/doc/CLI.md#json-output-format. I think the command should give this kind of output:
$ pgagroal-admin user ls --format json
{
"command": {
"name": "user ls",
"status": "OK",
"error": 0,
"exit-status": 0,
"output": {
"users": {
"count": 2,
"list": [ "luca", "jesper" ]
}
}
},
"application": {
"name": "pgagroal-admin",
"major": 1,
"minor": 7,
"patch": 0,
"version": "1.7.0"
}
}
or something simpler, but the above should be for free using the json.c
stuff.
@fluca1978 Hey Luca, I think this version is what you want~ However I'm not sure if these json manipulations should be encapsulated into a function, so I completed the functionality first. If you think encapsulation is necessary, please give me some suggestions on the name and where to place it~
I'll add this option into documentation if there's no other problems with this version~
Since the output data is very simple, I directly use printf to output in JSON format in the original function.
I think my implementation is the simplest and most reliable implementation considering the complexity of the data. Of course, if you have a better idea, please tell me.
If there are other use cases that need support, please let me know ~ I will complete the documentation after completing all use cases~