From owner-soc-status@FreeBSD.ORG Mon Jun 2 13:31:28 2014 Return-Path: Delivered-To: soc-status@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id F0619373 for ; Mon, 2 Jun 2014 13:31:28 +0000 (UTC) Received: from theravensnest.org (theraven.freebsd.your.org [216.14.102.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cloud.theravensnest.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id BBA08256F for ; Mon, 2 Jun 2014 13:31:28 +0000 (UTC) Received: from dhcp-172-17-153-180.eduroam.lapwing.private.cam.ac.uk (global-1-26.nat.csx.cam.ac.uk [131.111.184.26]) (authenticated bits=0) by theravensnest.org (8.14.7/8.14.7) with ESMTP id s52DVGbu060688 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Mon, 2 Jun 2014 13:31:20 GMT (envelope-from theraven@theravensnest.org) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: [Machine readable output from userland utilities] report From: David Chisnall In-Reply-To: <1AE4C0BE-546E-4B02-9664-F460F948794F@mail.bg> Date: Mon, 2 Jun 2014 14:31:11 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <0FCB749A-67F7-4C2F-AAC1-32D0BD67B502@theravensnest.org> References: <8D1B686D-1AAA-4E07-9270-E42699110561@mail.bg> <1AE4C0BE-546E-4B02-9664-F460F948794F@mail.bg> To: Zaro Korchev X-Mailer: Apple Mail (2.1874) Cc: soc-status@freebsd.org X-BeenThere: soc-status@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Summer of Code Status Reports and Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Jun 2014 13:31:29 -0000 On 2 Jun 2014, at 12:43, Zaro Korchev wrote: > At the moment both ls and vmstat are told to output JSON by specifying = the -O option. However as I discussed with my mentor, this will be = changed. The idea is to use an environment variable instead of the -O = flag. I don't like the idea of using an environment variable, because this is = something that you might want to control on a per-command basis within a = pipeline. Especially with respect to incremental adoption, if you have = some commands that will emit their default format, which is sent to sed = / awk whatever, and some that will emit json natively, you don't want to = suddenly have the output format from the legacy tools change once they = gain machine-readable output support. One *very* important thing to do is standardise the command-line flag = that is used to specify the output format. This may involve also = converting some of the tools to use getopt_long if they don't already = (lots of tools already use most single-digit options, so there's no = possibility to define a single-letter flag that will be useable on all = tools). =20 > I understand your concerns about multi-threading. The idea is to have = functions that serialize the object in an allocated buffer as it is = constructed. Here is a more detailed example of what I mean: It would be better to has some stream output API as the default. If one = back end only supports writing to buffers, then you can add an extra = alloc / write / free sequence to hide it, but it would be good if the = interface understands writing directly to file descriptors. If the back = end natively supports streaming, then you don't need to buffer the = output. David