From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 0/2] Parsing a subcommand using parse-options
Date: Thu, 8 Dec 2011 17:37:06 +0530 [thread overview]
Message-ID: <1323346028-9201-1-git-send-email-artagnon@gmail.com> (raw)
Hi,
It's been itching me for some time now: I want parse-options to be
able to parse a "subcommand". It all started when I noticed how ugly
my implementation of '--continue' and '--quit' in git-revert were:
using an OPT_BOOLEAN to parse the option into separate integer
variables, and then using if-else constructs to turn that into an
enum. Yuck! Also, wouldn't we all love something like this in the
future?
git stash show
^^ -- The subcommand "show" to the git-stash builtin
Ofcourse, git-stash.sh is just a shell script, and the full motivation
doesn't arise until someone decides to turn it into a C builtin. So,
I went hunting for a C builtin that used subcommands and found
something relatively obscure: git-bundle. It does option-parsing by
hand; changing it to use parse-options is the perfect opportunity to
implement this subcommand feature!
Thoughts?
-- Ram
Ramkumar Ramachandra (2):
parse-options: introduce OPT_SUBCOMMAND
bundle: rewrite builtin to use parse-options
builtin/bundle.c | 111 ++++++++++++++++++++++++++++++----------------
parse-options.c | 5 +-
parse-options.h | 3 +
t/t0040-parse-options.sh | 31 +++++++++++++
test-parse-options.c | 4 ++
5 files changed, 114 insertions(+), 40 deletions(-)
--
1.7.7.3
next reply other threads:[~2011-12-08 12:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-08 12:07 Ramkumar Ramachandra [this message]
2011-12-08 12:07 ` [PATCH 1/2] parse-options: introduce OPT_SUBCOMMAND Ramkumar Ramachandra
2011-12-08 12:07 ` [PATCH 2/2] bundle: rewrite builtin to use parse-options Ramkumar Ramachandra
2011-12-08 19:51 ` [PATCH 0/2] Parsing a subcommand using parse-options Junio C Hamano
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=1323346028-9201-1-git-send-email-artagnon@gmail.com \
--to=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).