nicohman / wyvern

A simple CLI client for installing and maintaining linux GOG games
GNU General Public License v3.0
87 stars 5 forks source link

Option to return in json format for better batch and automation support. #7

Closed sigboe closed 5 years ago

sigboe commented 5 years ago

Could you have the option to return in json instead of plain text?

Right now I do crazy stuff like mapfile -t myLibrary < <(wyvern ls | perl -pe 's:\ -\ (?!.*\ -\ ):;:g' | awk -F';' '{print $2 "\n" $1}')

:smile:

nicohman commented 5 years ago

This'll be put onto the todo list, and I'll add it after I finish up the 1.2 release.

nicohman commented 5 years ago

I added a JSON option to the list command and the connect games list, but I'm not sure if there's really many other places where a JSON option would be useful. Are there any other commands that you'd like a JSON option for?

sigboe commented 5 years ago

As of right now, I don't see anywhere else. I am super grateful for also getting json option in connect.

Its only if you would add an option to list extras. Or an option to check what the newest version is, to know if you want to update.

I'll also give you access to my repo (which is private, just until it works), so you can if you want see what I am working on. I am not asking for help (other than suggestions for improvements to your app), but I feel like since you are the reason its possible you should be able to see it. Even though i dont ask for help, feel free to comment, suggest, or do anything.

sigboe commented 5 years ago

Also the error message when there is no games available on connect is not formatted in json

nicohman commented 5 years ago

I'd prefer to keep the error message to the current format, as it matches the format of all other error messages within the program. This way, it should be easier for scripts to interpret the result, as they can check for errors with a single search, rather than having to change error-handling code depending on whether or not they want a JSON output.

sigboe commented 5 years ago

Right now the json format is like an array within an array.

{
  "games": [
    [ "Unreal Gold", 1207658679 ],
    [ "Theme Hospital", 1207659026 ],
    [ "Knights of Pen and Paper +1 Edition", 1320675280 ],
  ]
}

This is fine, it is predictable easily usable.

I just wonder if it can be more useful to have an array with objects, can even have more information with it? Just an example:

{
  "games": [
    { "name":"Unreal Gold", "id":1207658679 "filesize":233997336, "url":"https://www.gog.com/game/unreal_gold" },
    { "name":"Theme Hospital", "id":1207659026, "filesize":172101616, "url":"https://www.gog.com/game/theme_hospital" },
    { "name":"Knights of Pen and Paper +1 Edition", "id":1320675280, "filesize":27850841, "url":"https://www.gog.com/game/knights_of_pen_and_paper_1_edition" }
  ]
}

Just thinking out loud here.

nicohman commented 5 years ago

I pushed commit 2b04049, which now prints all of the metadata given from the productdetails call when it's called with --json. Let me know if you want a way to get any more metadata.