linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Goffredo Baroncelli <kreijack@libero.it>
To: Ilya Dryomov <idryomov@gmail.com>
Cc: linux-btrfs@vger.kernel.org, Chris Mason <chris.mason@oracle.com>
Subject: Re: [PATCH 2/3] Btrfs-progs: implement new subcommand parser
Date: Tue, 7 Feb 2012 00:12:13 +0100	[thread overview]
Message-ID: <201202070012.13956.kreijack@libero.it> (raw)
In-Reply-To: <20120204144525.GA10916@zambezi.lan>

On Saturday, 04 February, 2012 15:45:25 Ilya Dryomov wrote:
> On Sat, Feb 04, 2012 at 01:54:23PM +0100, Goffredo Baroncelli wrote:
> > Hi Ilya
> > 
> > On Friday, 03 February, 2012 22:23:59 you wrote:
> > > This completely replaces the existing subcommand infrastructure, which
> > > is not flexible enough to accomodate our needs.
> > 
> > Could you explain what you means with "our needs" ?
> 
> Hi Goffredo,
> 
> I've described the problem earlier: I need to preserve the old behaviour
> of 'btrfs fi balance <path>', and I can't do that when all I'm able to
> do is to assign individual command handlers.  In addition we might want
> to have per-command-group options in future, which won't be possible w/o
> a complete rewrite of the current system.
> 
> > > Instead of a global
> > > command table we now have per-level tables and command group handlers,
> > > which allows command-group-specific handling of options and
> > > subcommands. The new parser exports a clear interface and gets out of
> > > the way - all control over how matching is done is passed to commands
> > > and command group handlers.
> > 
> > The same could be done with the actual system. For example if you want to
> > to handle the "filesystem balance" subcommands family, you could handle
> > every syntax you want with changing the function do_balance; without
> > forcing everybody to develop a "group handlers". Of course a bit of work
> > should be done on the handling the help.
> 
> Nope, it couldn't.  I didn't really want to do all this work so I went
> that way first.  But the problem is that ambiguity interface, help
> interface and everything else is buried deep in the parser and is not
> exported.  Suppose I change do_balance(), then I have to write my own
> ambiguity engine to handle balance commands (eg I have 'start' and
> 'status'), I have to write my own usage/help functions, I have to fixup
> argv array so it contains the right subcommand name, etc, etc.

I am not enterely convinced that you cannot do this with the actual parser 
implementation. 

However, looking at your code it seems fine to me. I like the help system. My 
only suggestion is to move some checks (like the argument counting check) in a 
more centralized way where possible.

Beside that, I am still not happy about having "balance" both as single 
command and as "group". But this is a completely different question.

BR
G.Baroncelli.

  reply	other threads:[~2012-02-06 23:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-03 21:23 [PATCH 0/3] Btrfs-progs: new subcommand infrastructure Ilya Dryomov
2012-02-03 21:23 ` [PATCH 2/3] Btrfs-progs: implement new subcommand parser Ilya Dryomov
2012-02-04 12:54   ` Goffredo Baroncelli
2012-02-04 14:45     ` Ilya Dryomov
2012-02-06 23:12       ` Goffredo Baroncelli [this message]
2012-02-03 21:24 ` [PATCH 3/3] Btrfs-progs: switch all existing commands to a new parser Ilya Dryomov

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=201202070012.13956.kreijack@libero.it \
    --to=kreijack@libero.it \
    --cc=chris.mason@oracle.com \
    --cc=idryomov@gmail.com \
    --cc=linux-btrfs@vger.kernel.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 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).