mas icon indicating copy to clipboard operation
mas copied to clipboard

JSON output option

Open cdalvaro opened this issue 6 years ago • 10 comments

It would be nice to have a parameter like --json when listing or searching apps.

I have tried to parse the current output, which is not very difficult, but it can stop working at any time if the output format is changed.

This could help to create an API for automation.

For example, instead of:

mas list
424389933 Final Cut Pro (10.4.4)
409183694 Keynote (8.3)
409203825 Numbers (5.3)
409201541 Pages (7.3)

get something like:

mas list --json
[{"name":"Final Cut Pro","version":"10.4.4","id":424389933},{"name":"Keynote","version":"8.3","id":409183694},{"name":"Numbers","version":"5.3","id":409203825},{"name":"Pages","version":"7.3","id":409201541}]
[
  {
    "name": "Final Cut Pro",
    "version": "10.4.4",
    "id": 424389933
  },
  {
    "name": "Keynote",
    "version": "8.3",
    "id": 409183694
  },
  {
    "name": "Numbers",
    "version": "5.3",
    "id": 409203825
  },
  {
    "name": "Pages",
    "version": "7.3",
    "id": 409201541
  }
]

cdalvaro avatar Dec 26 '18 14:12 cdalvaro

Great idea. I've been thinking along the same lines. The existing output formatting is very ad-hoc and inconsistent between commands without much design behind it. App names can sometimes be quite long due to SEO efforts and thus parsing errors could arise even with the existing formats if numbers and special characters are embedded. I want to add a formatting layer so that the various supported formats can easily be toggled.

Is the a specific use case you are looking to automate? Are there any attributes that you would like to see added? The current text output doesn't lend itself to including a lot of data, but this output could be a lot more verbose in JSON as it doesn't need to fit easily on a terminal screen.

phatblat avatar Dec 27 '18 15:12 phatblat

I'm working on a SaltStack module/state for automating the management of Mac App Store applications. (That is the reason of my comment in #89)

Your mas package is perfect for this purpose, but I need some information, mainly the three parameters commented in the description (id, name and version), in order to control changes, and a stable API that won't change too much in time. (That is the reason of this suggestion)

At the moment, I don't have found any situation in which I have needed more information than the three parameters requested. Although, by returning a JSON, more information could be added later without breaking the API.

cdalvaro avatar Dec 27 '18 15:12 cdalvaro

Hi! Is there any progress on this issue??

cdalvaro avatar Oct 03 '20 17:10 cdalvaro

It would be neat to have a --json5 option too, mostly for the unquoted keys.

phatblat avatar Jun 09 '21 23:06 phatblat