All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Markus Armbruster <armbru@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-block] Non-flat command line option argument syntax
Date: Fri, 3 Feb 2017 21:02:42 +0100	[thread overview]
Message-ID: <6e65ad3c-db00-0ce5-a9c6-0e8ba84ad3c6@redhat.com> (raw)
In-Reply-To: <87shnvhfwc.fsf@dusky.pond.sub.org>

[-- Attachment #1: Type: text/plain, Size: 4070 bytes --]

On 03.02.2017 08:50, Markus Armbruster wrote:
> "Dr. David Alan Gilbert" <dgilbert@redhat.com> writes:
> 
>> * Markus Armbruster (armbru@redhat.com) wrote:
>>> = Introduction =
>>>
>>
>> <snip>
>>
>>> = Structured option argument syntax =
>>>
>>> == JSON ==
>>>
>>> The obvious way to provide the expressiveness of JSON on the command
>>> line is JSON.  Easy enough[2].  However, besides not being compatible,
>>> it's rather heavy on syntax, at least for simple cases.  Compare:
>>>
>>>     -machine q35,accel=kvm
>>>     -machine '{ "type": "q35", "accel": "kvm"}'
>>>
>>> It compares a bit more favourably in cases that use our non-flat hacks.
>>> Here's a flat list as KEY=VALUE,... with repeated keys, and as JSON:
>>>
>>>     -semihosting-config enable,arg=eins,arg=zwei,arg=drei
>>>     -semihosting-config '{ "enable": true, "arg": [ "eins", "zwei", "drei" ] }'
>>>
>>> Arbitrary nesting with dotted key convention:
>>>
>>>     -drive driver=qcow2,file.driver=gluster,
>>>            file.volume=testvol,file.path=/path/a.qcow2,file.debug=9,
>>>            file.server.0.type=tcp,
>>>            file.server.0.host=1.2.3.4,
>>>            file.server.0.port=24007,
>>>            file.server.1.type=unix,
>>>            file.server.1.socket=/var/run/glusterd.socket
>>>     -drive '{ "driver": "qcow2",
>>>               "file": {
>>>                   "driver": "gluster", "volume": "testvol",
>>>                   "path": "/path/a.qcow2", "debug": 9,
>>>                   "server": [ { "type": "tcp",
>>>                                 "host": "1.2.3.4", "port": "24007"},
>>>                               { "type": "unix",
>>>                                 "socket": "/var/run/glusterd.socket" } ] } }'
>>
>> So while I generally hate JSON, the -drive dotted key syntax makes
>> me mad when it gets like this;  have a look
>> at the block replication and quorum setups especially, that can end up
>> with (from docs/COLO-FT.txt):
>>
>>   -drive if=virtio,id=primary-disk0,driver=quorum,read-pattern=fifo,vote-threshold=1,\
>>          children.0.file.filename=1.raw,\
>>          children.0.driver=raw -S
>>
>>    that's just way too many .'s to ever properly understand.
>> (I'm sure it used to be more complex).
> 
> Here's an idea to cut down on the dottery that drives you mad (and me
> too): if KEY starts with '.', combine it with a prefix of the previous
> one so that the result has the same number of name components.
> 
> Your example becomes
> 
>     -drive if=virtio,id=primary-disk0,driver=quorum,read-pattern=fifo,vote-threshold=1,\
>            children.0.file.filename=1.raw,.driver=raw -S

No, the last option would be children.0.file.driver=raw when expanded
(which is wrong, it should be children.0.driver).

> 
> My example
> 
>      -drive driver=qcow2,file.driver=gluster,
>             file.volume=testvol,file.path=/path/a.qcow2,file.debug=9,
>             file.server.0.type=tcp,
>             file.server.0.host=1.2.3.4,
>             file.server.0.port=24007,
>             file.server.1.type=unix,
>             file.server.1.socket=/var/run/glusterd.socket
> 
> becomes
> 
>      -drive driver=qcow2,
>             file.driver=gluster,
>                 .volume=testvol,
>                 .path=/path/a.qcow2,
>                 .debug=9,
>             file.server.0.type=tcp,
>                          .host=1.2.3.4,
>                          .port=24007,
>             file.server.1.type=unix,
>                          .socket=/var/run/glusterd.socket
> 
> Mind, I'm not at all sure this is a *good* idea.  I suspect it's more
> magic than it's worth.

As someone who likes dot syntax very much, I don't like it. If you
structure it like this, it's OK, but then you can just write the full
prefix (which gets the point across just as well because I can quickly
tell from a glance that it's the same prefix).

OTOH, when joined into a single line it doesn't change much in terms of
legibility, in my opinion.

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 512 bytes --]

  parent reply	other threads:[~2017-02-03 20:02 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-02 19:42 [Qemu-devel] Non-flat command line option argument syntax Markus Armbruster
2017-02-02 20:06 ` Eric Blake
2017-02-02 20:23 ` Eric Blake
2017-02-03  7:57   ` Markus Armbruster
2017-02-02 20:27 ` Dr. David Alan Gilbert
2017-02-03  7:50   ` Markus Armbruster
2017-02-03 16:57     ` Dr. David Alan Gilbert
2017-02-04  9:44       ` Markus Armbruster
2017-02-06 10:20         ` Dr. David Alan Gilbert
2017-02-03 20:02     ` Max Reitz [this message]
2017-02-04  9:45       ` [Qemu-devel] [Qemu-block] " Markus Armbruster
2017-02-04 10:03         ` [Qemu-devel] " Paolo Bonzini
2017-02-04 11:52           ` Markus Armbruster
2017-02-04 12:43             ` Paolo Bonzini
2017-02-03 10:03 ` Daniel P. Berrange
2017-02-03 11:13   ` Markus Armbruster
2017-02-03 12:37 ` Peter Krempa
2017-02-03 13:53   ` Markus Armbruster
2017-02-03 17:25 ` Richard W.M. Jones
2017-02-04  9:51   ` Markus Armbruster
2017-02-05 20:46     ` [Qemu-devel] [Qemu-block] " Max Reitz
2017-02-03 20:28 ` Max Reitz
2017-02-04  9:56   ` Markus Armbruster
2017-02-04 12:21 ` [Qemu-devel] " Fam Zheng
2017-02-04 12:44   ` Paolo Bonzini
2017-02-04 13:02     ` Fam Zheng
2017-02-04 13:35   ` Markus Armbruster
2017-02-04 14:10     ` Fam Zheng
2017-02-06  6:24       ` Markus Armbruster
2017-02-06 11:08   ` Daniel P. Berrange
2017-02-06  6:57 ` Markus Armbruster
2017-02-06 13:23 ` Kevin Wolf
2017-02-06 15:36   ` Markus Armbruster
2017-02-06 16:33     ` Daniel P. Berrange
2017-02-06 17:24       ` Markus Armbruster
2017-02-06 17:50         ` Daniel P. Berrange
2017-02-06 18:56           ` Markus Armbruster
2017-02-06 17:38     ` Paolo Bonzini
2017-02-06 18:12       ` Markus Armbruster
2017-02-06 21:52         ` Paolo Bonzini
2017-02-07  7:02           ` Markus Armbruster
2017-02-07  9:26     ` Kevin Wolf
2017-02-24 16:04 ` Markus Armbruster
2017-02-24 16:39   ` Daniel P. Berrange
2017-02-24 17:17     ` Eric Blake
2017-02-24 19:15       ` Markus Armbruster
2017-02-27 10:27 ` Markus Armbruster
2017-02-27 10:59   ` Kevin Wolf
2017-02-27 13:36     ` Markus Armbruster
2017-02-27 19:47       ` Eric Blake
2017-02-28  8:24         ` Markus Armbruster
2017-02-27 19:43   ` Eric Blake
2017-02-28  8:41     ` Markus Armbruster
2017-03-01  9:24 ` Markus Armbruster
2017-03-21  8:40 ` Markus Armbruster

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=6e65ad3c-db00-0ce5-a9c6-0e8ba84ad3c6@redhat.com \
    --to=mreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.