From: "Austin S. Hemmelgarn" <ahferroin7@gmail.com>
To: dsterba@suse.cz, "Richard W.M. Jones" <rjones@redhat.com>,
linux-btrfs@vger.kernel.org, ptoscano@redhat.com
Subject: Re: RFE: 'btrfs' tools machine readable output
Date: Tue, 17 May 2016 09:05:38 -0400 [thread overview]
Message-ID: <b9136e93-2099-245e-46a0-941d72279e1f@gmail.com> (raw)
In-Reply-To: <20160517122326.GJ511@twin.jikos.cz>
On 2016-05-17 08:23, David Sterba wrote:
> On Tue, May 17, 2016 at 07:14:12AM -0400, Austin S. Hemmelgarn wrote:
>>>> By this example I don't mean that JSON has to be the format -- in fact
>>>> it's a terrible format with all sorts of problems -- any format which
>>>> is parseable with C libraries would do for us.
>>>
>>> My ideas was to allow multiple formats, with slight change to the
>>> syntax:
>>>
>>> $ btrfs --format=json ...
>>> $ btrfs --format=plain ...
>>> $ btrfs --format=yaml ...
>> I like this idea, with one specific caveat, it would be _really_ nice to
>> be able to control at compile time what formats are supported.
>> Somebody's eventually going to want XML support, and I'd rather not have
>> to depend on expat or something similar in a tool that I regularly build
>> statically (I'm willing to tolerate YAML because that's what I'd use,
>> but I would probably compile out the JSON support too).
>
> I hope we can avoid any 3rd party library dependencies, we're just
> generating the output not parsing it. Either copy a version of the
> libraries or copy the quoting code, the rest can be simply implemented as
> a printf with enhanced format stings.
>
As much as I hate the possibility of having 3rd party library
dependencies in btrfs-progs, I'm a lot more nervous about having the
equivalent stuff open-coded or having a local copy of the library, as
both have significant potential for bugs. A significant majority of
Linux systems have Python, and therefore have at least some XML library
(I forget which one Python prefers to use). Many also have at least one
JSON library too. If we make such dependencies optional, and also only
load the library if we need it at runtime (so we would only load the
JSON library if we are asked to print JSON output), then we could still
avoid the overhead for most people.
The other possibility would be to just pick one output format, open code
that, and be done with it. It's not hard to write s simple script to
convert between YAML, JSON, and other similar formats. If we do go this
way, I'd still suggest YAML as it's more human friendly, a lot easier to
parse using scripts due to the line oriented nature of it, and is also
probably easier to code without any external dependencies.
next prev parent reply other threads:[~2016-05-17 13:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-16 12:14 RFE: 'btrfs' tools machine readable output Richard W.M. Jones
2016-05-16 12:21 ` Martin Steigerwald
2016-05-16 12:39 ` Richard W.M. Jones
2016-05-16 12:46 ` Pino Toscano
2016-05-16 12:39 ` Austin S. Hemmelgarn
2016-05-27 19:47 ` Nicholas D Steeves
2016-05-31 12:15 ` Austin S. Hemmelgarn
2016-05-17 9:33 ` David Sterba
2016-05-17 11:14 ` Austin S. Hemmelgarn
2016-05-17 12:23 ` David Sterba
2016-05-17 13:05 ` Austin S. Hemmelgarn [this message]
2016-05-17 13:32 ` Richard W.M. Jones
2016-05-17 15:04 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b9136e93-2099-245e-46a0-941d72279e1f@gmail.com \
--to=ahferroin7@gmail.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=ptoscano@redhat.com \
--cc=rjones@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).