Ok.  Thanks, Mitchell.

On Friday, March 21, 2014 5:01:51 PM UTC-4, Mitchell Hashimoto wrote:
>
> Todd, 
>
> The core is very unfriendly to this sort of output and is very much 
> line-oriented. Instead, it might be better for a separate library to 
> parse the Vagrant machine readable output and turn it into JSON. 
>
> Best, 
> Mitchell 
>
> On Fri, Mar 21, 2014 at 1:59 PM, Todd DeLuca 
> <[email protected]<javascript:>> 
> wrote: 
> > Hi Mitchell, et al., 
> > 
> > What do you think about using JSON as a machine readable output? 
> > 
> > The current machine readable output format burdens users with parsing a 
> > sparsely documented ad hoc format, albeit one that is more structured 
> than 
> > the default vagrant output.  Without very thorough documentation it is 
> > difficult to know if one is parsing the machine readable output 
> correctly. 
> > This makes it only slightly better than the default (non-machine 
> readable) 
> > sparsely documented ad hoc output, at least for my purposes.  (I 
> maintain 
> > python-vagrant: https://github.com/todddeluca/python-vagrant). 
> > 
> > Contrast this with JSON.  JSON requires no parsing, assuming you have a 
> JSON 
> > parser for your language of choice.  It can easily represent complex 
> nested 
> > data structures.  If a user wants to process the output using command 
> line 
> > tools, they can use jq (http://stedolan.github.io/jq/), which is like 
> sed 
> > for JSON, according to its docs. 
> > 
> > Here is an example of machine readable output: 
> > 
> > $ vagrant box list --machine-readable 
> > 1395431215,,box-name,precise32 
> > 1395431215,,box-provider,virtualbox 
> > 1395431215,,box-version,0 
> > 1395431216,,box-name,precise64 
> > 1395431216,,box-provider,virtualbox 
> > 1395431216,,box-version,0 
> > 1395431216,,box-name,python-vagrant-base 
> > 1395431216,,box-provider,virtualbox 
> > 1395431216,,box-version,0 
> > 1395431216,,box-name,trusty64 
> > 1395431216,,box-provider,virtualbox 
> > 1395431216,,box-version,0 
> > 
> > Since the information for one box is spread across multiple lines, the 
> > parsing required is more sophisticated than that for a simple CSV table. 
> > With no begin and end tags, to parse the data you must intimately 
> understand 
> > how each line relates to the others. 
> > 
> > Here is a hypothetical JSON version of the box output above: 
> > 
> > $ vagrant box list --json 
> > [ 
> >   { 
> >     "target": null, 
> >     "timestamp": 1395431215, 
> >     "box-name": "precise32", 
> >     "box-version": "0", 
> >     "type": "box-list", 
> >     "box-provider": "virtualbox" 
> >   }, 
> >   { 
> >     "target": null, 
> >     "timestamp": 1395431216, 
> >     "box-name": "precise64", 
> >     "box-version": "0", 
> >     "type": "box-list", 
> >     "box-provider": "virtualbox" 
> >   }, 
> >   { 
> >     "target": null, 
> >     "timestamp": 1395431216, 
> >     "box-name": "python-vagrant-base", 
> >     "box-version": "0", 
> >     "type": "box-list", 
> >     "box-provider": "virtualbox" 
> >   }, 
> >   { 
> >     "target": null, 
> >     "timestamp": 1395431216, 
> >     "box-name": "trusty64", 
> >     "box-version": "0", 
> >     "type": "box-list", 
> >     "box-provider": "virtualbox" 
> >   } 
> > ] 
> > 
> > And to demonstrate how `jq` can manipulate this data on the command 
> line, 
> > here is an example using `jq` to select the "trusty64" box: 
> > 
> > $ vagrant box list --json | jq '.[] | select(.["box-name"] == 
> "trusty64")' 
> > { 
> >   "box-provider": "virtualbox", 
> >   "type": "box-list", 
> >   "box-version": "0", 
> >   "box-name": "trusty64", 
> >   "timestamp": 1395431216, 
> >   "target": null 
> > } 
> > 
> > Is this the right place to make these feature requests?  Should I open 
> an 
> > issue on GitHub? 
> > 
> > Regards, 
> > Todd 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Vagrant" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to [email protected] <javascript:>. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to