Hey,
as i don't really grasp the way all that cli output and formatting is done i would ask if you could either change the output of the grommunio-admin user login apiuser@dom.tld --token --nopass output to something more useful like this (IMHO)
diff --git a/cli/user.py b/cli/user.py
index 4814c0f..0ff2980 100644
--- a/cli/user.py
+++ b/cli/user.py
@@ -320,6 +320,7 @@ def cliUserDelete(args):
def cliUserLogin(args):
+ import json
cli = args._cli
cli.require("DB")
from orm.users import Users
@@ -345,8 +346,10 @@ def cliUserLogin(args):
cli.print(cli.col("Login ok.", "green"))
else:
token = mkJWT({"usr": user.username})
+ cookie = f'grommunioAuthJwt={token}'
csrf = mkCSRF(token)
- cli.print(cli.col("Token: ", attrs=["bold"])+token+"\n"+cli.col("CSRF: ", attrs=["bold"])+csrf)
+ print(json.dumps({'Cookie': cookie, 'X-CSRF-TOKEN': csrf}))
+ #cli.print(cli.col("", attrs=["bold"])+token+"\n"+cli.col("CSRF: ", attrs=["bold"])+csrf)
def _cliUserDevicesDecodeSyncState(args, data, username):
haven't tried it yet but i could at least store this output and use it with e.g. curl w/o having to awk/sed my way over the output i get with the current implementation and anyone who wants text can just throw it at | jq and still be able to copy/paste it some place.
What would probably be a better thing to do is to add a general --format to any type of command which will return something.
I mean shiny colours are nice and all but sometimes they can also be very annoying if you want to parse the output, and i'm not even talking about a script but just your basic one-liner will be way more work to write on the spot.
The command i'm mostly thinking of is grommunio-admin ldap downsync ... and as you can probably guess it's about these "...success" / "...no changes" and whatever might come up aswell. On some systems they are even coloured (tho i don't know which library is the culprit in allowing it to change the behaviour).
Anyhow, if such a output would also be available as csv and json with documented (talking about the manpage) fields this could be really helpful.
The api already has those afaics so it shouldn't be to much of a hassle?
{
"data": [
{
"ID": 1,
"code": 200,
"message": "Synchronization successful",
"username": "cb@clownflare.de"
},
....
],
"message": "26/26 synced (0.4s)"
}
That code 200 sounds more like a http return and not like sysexits.h(3) but as long as they are documented it would not really make a difference.
Genug gebabbelt... o/
Hey,
as i don't really grasp the way all that cli output and formatting is done i would ask if you could either change the output of the
grommunio-admin user login apiuser@dom.tld --token --nopassoutput to something more useful like this (IMHO)What would probably be a better thing to do is to add a general
--formatto any type of command which will return something.I mean shiny colours are nice and all but sometimes they can also be very annoying if you want to parse the output, and i'm not even talking about a script but just your basic one-liner will be way more work to write on the spot.
The command i'm mostly thinking of is
grommunio-admin ldap downsync ...and as you can probably guess it's about these "...success" / "...no changes" and whatever might come up aswell. On some systems they are even coloured (tho i don't know which library is the culprit in allowing it to change the behaviour).Anyhow, if such a output would also be available as csv and json with documented (talking about the manpage) fields this could be really helpful.
The api already has those afaics so it shouldn't be to much of a hassle?
{ "data": [ { "ID": 1, "code": 200, "message": "Synchronization successful", "username": "cb@clownflare.de" }, .... ], "message": "26/26 synced (0.4s)" }That code 200 sounds more like a http return and not like sysexits.h(3) but as long as they are documented it would not really make a difference.
Genug gebabbelt... o/