From: Pierre Habouzit <madcoder@debian.org>
To: Mike Hommey <mh@glandium.org>
Cc: "Kristian Høgsberg" <krh@redhat.com>,
git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>
Subject: Re: [ALTERNATE PATCH] Add a simple option parser.
Date: Fri, 05 Oct 2007 16:45:40 +0200 [thread overview]
Message-ID: <20071005144540.GM19879@artemis.corp> (raw)
In-Reply-To: <20071005143014.GA18176@glandium.org>
[-- Attachment #1: Type: text/plain, Size: 1575 bytes --]
On Fri, Oct 05, 2007 at 02:30:14PM +0000, Mike Hommey wrote:
> On Fri, Oct 05, 2007 at 04:25:07PM +0200, Pierre Habouzit <madcoder@debian.org> 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.
> >
> > Aggregation of single switches is allowed:
> > -rC0 is the same as -r -C 0 (supposing that -C wants an arg).
>
> I like options aggregation, but I'm not sure aggregating option arguments
> is a good idea... I can't even think of an application that does it.
You mean like `grep -A1` or `diff -u3` or `ls -w10` ?
getopt does that by default as well, so you may not have aware of it,
but it's how things work in your system already.
btw `ls -rw10` works, though `ls -w10r` drops the 'r' silently. FWIW I
don't, in that case, the alternate patch I propose complains about "10r"
not being a valid integer, and that's because unlike getopt, the patch
krh proposed knows what an integer is ;)
--
·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-05 14:45 UTC|newest]
Thread overview: 26+ 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
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 [this message]
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
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=20071005144540.GM19879@artemis.corp \
--to=madcoder@debian.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=krh@redhat.com \
--cc=mh@glandium.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).