From: Pierre Habouzit <madcoder@debian.org>
To: "Kristian Høgsberg" <krh@redhat.com>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] Add a simple option parser.
Date: Thu, 04 Oct 2007 17:15:32 +0200 [thread overview]
Message-ID: <20071004151532.GB5083@artemis.corp> (raw)
In-Reply-To: <1191509878.29379.2.camel@hinata.boston.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2510 bytes --]
On Thu, Oct 04, 2007 at 02:57:58PM +0000, Kristian Høgsberg wrote:
>
> On Thu, 2007-10-04 at 01:11 +0200, Pierre Habouzit wrote:
> > On Wed, Oct 03, 2007 at 09:45:01PM +0000, Kristian Høgsberg wrote:
> > > The option parser takes argc, argv, an array of struct option
> > > and a usage string. Each of the struct option elements in the array
> > > describes a valid option, its type and a pointer to the location where the
> > > value is written. The entry point is parse_options(), which scans through
> > > the given argv, and matches each option there against the list of valid
> > > options. During the scan, argv is rewritten to only contain the
> > > non-option command line arguments and the number of these is returned.
> >
> > if we are going in that direction (and I believe it's a good one), we
> > should be sure that the model fits with other commands as well. And as I
> > said on IRC, I believe the most "horrible" (as in complex) option parser
> > in git is the one from git-grep.
> >
> > A migration of git-grep on that API should be tried first. If this
> > works well enough, I believe that the rest of the git commands will be
> > migrated easily enough. (with maybe small addition to parse-option.[hc]
> > but the hardcore things should have been met with git-grep already I
> > think).
>
> I'm not sure - we can go with the current proposal and add new options
> types and probably the callback option type I suggested as we go. I
> don't want to block builtin-commit on figuring out what the perfect
> option parser should look like and what I sent out earlier work for
> commit. I think the way you handled the strbuf rewrites worked pretty
> well; extending and rewriting the API as you put it to use in more and
> more places. We can do the same thing with parse_options().
Of course we can do that, or junio said that some people talked about
popt some time ago. I understand that you don't want to block the
git-commit work, but doing things right from the beginning is often a
big win on the long term.
I don't know popt, and I don't know if it has sufficient expressivity.
For sure I don't like getopt_long APIs at all, so if popt is as
cumbersome, rolling our own based on the current parse_options you
propose is probably a good choice.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2007-10-04 15:15 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-03 21:45 [PATCH] Add a simple option parser Kristian Høgsberg
2007-10-03 21:45 ` [PATCH] Port builtin-add.c to use the new " Kristian Høgsberg
2007-10-03 23:11 ` [PATCH] Add a simple " Pierre Habouzit
2007-10-04 14:57 ` Kristian Høgsberg
2007-10-04 15:15 ` Pierre Habouzit [this message]
2007-10-04 16:31 ` Pierre Habouzit
2007-10-04 16:39 ` Johannes Schindelin
2007-10-05 10:08 ` Pierre Habouzit
2007-10-05 14:21 ` Pierre Habouzit
2007-10-05 14:25 ` [ALTERNATE PATCH] " Pierre Habouzit
2007-10-05 14:30 ` Mike Hommey
2007-10-05 14:45 ` Pierre Habouzit
2007-10-05 15:45 ` Medve Emilian-EMMEDVE1
2007-10-05 15:56 ` Pierre Habouzit
2007-10-05 16:10 ` Medve Emilian-EMMEDVE1
2007-10-05 16:20 ` David Kastrup
2007-10-05 16:38 ` Pierre Habouzit
2007-10-06 8:46 ` Sven Verdoolaege
2007-10-05 16:28 ` Linus Torvalds
2007-10-05 16:41 ` Medve Emilian-EMMEDVE1
2007-10-05 16:49 ` Pierre Habouzit
2007-10-05 16:51 ` Linus Torvalds
2007-10-05 14:59 ` David Kastrup
2007-10-05 15:33 ` Kristian Høgsberg
2007-10-05 15:54 ` Pierre Habouzit
2007-10-07 17:01 ` Pierre Habouzit
-- strict thread matches above, loose matches on Subject: below --
2007-10-13 13:29 [RFC] CLI option parsing and usage generation for porcelains Pierre Habouzit
[not found] ` <1192282153-26684-2-git-send-email-madcoder@debian.org>
2007-10-13 14:39 ` [PATCH] Add a simple option parser Johannes Schindelin
2007-10-13 14:58 ` Pierre Habouzit
2007-10-13 19:16 ` Alex Riesen
2007-10-13 20:54 ` Pierre Habouzit
2007-10-13 22:14 ` Alex Riesen
2007-10-14 7:02 ` Pierre Habouzit
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=20071004151532.GB5083@artemis.corp \
--to=madcoder@debian.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=krh@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 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.