git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Robin H. Johnson" <robbat2@gentoo.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v3 1/3] bundle: framework for options before bundle file
Date: Mon, 11 Nov 2019 11:34:26 +0900	[thread overview]
Message-ID: <xmqqlfsni1jh.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20191110204126.30553-1-robbat2@gentoo.org> (Robin H. Johnson's message of "Sun, 10 Nov 2019 12:41:24 -0800")

"Robin H. Johnson" <robbat2@gentoo.org> writes:

> +static int verbose;
> +
> +static int parse_options_cmd_bundle(int argc,
> +		const char **argv,
> +		const char* prefix,
> +		const char * const usagestr[],
> +		const struct option options[],
> +		const char **bundle_file) {
> +	int newargc;
> +	newargc = parse_options(argc, argv, NULL, options, usagestr,
> +			     PARSE_OPT_STOP_AT_NON_OPTION);
> +	if (argc < 1)
> +		usage_with_options(usagestr, options);
> +	*bundle_file = prefix_filename(prefix, argv[0]);
> +	return newargc;
> +}

Looks like a useful helper to be shared among subcommands.

> +static int cmd_bundle_create(int argc, const char **argv, const char *prefix) {
> +	struct option options[] = {
> +		OPT_END()
> +	};
> +	const char* bundle_file;
> ...
> +int cmd_bundle(int argc, const char **argv, const char *prefix)
> +{
> +	struct option options[] = {
> +		OPT__VERBOSE(&verbose, N_("be verbose; must be placed before a subcommand")),
> +		OPT_END()
> +	};
> +	int result;
> +
> +	argc = parse_options(argc, argv, prefix, options, builtin_bundle_usage,
> +		PARSE_OPT_STOP_AT_NON_OPTION);

Looks like a reasonable arrangement for two-level option parser.

  parent reply	other threads:[~2019-11-11  2:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1f7f0aa1e8fae54bf967ae83a160be2b30db634f.1573248640.git.gitgitgadget@gmail.com>
2019-11-10 20:41 ` [PATCH v3 1/3] bundle: framework for options before bundle file Robin H. Johnson
2019-11-10 20:41   ` [PATCH v3 2/3] bundle-create: progress output control Robin H. Johnson
2019-11-11  4:07     ` Jeff King
2019-11-11  7:28       ` Robin H. Johnson
2019-11-11  8:10         ` Jeff King
2019-11-11  9:01           ` Junio C Hamano
2019-11-10 20:41   ` [PATCH v3 3/3] bundle-verify: add --quiet Robin H. Johnson
2019-11-11  4:09     ` Jeff King
2019-11-11  2:34   ` Junio C Hamano [this message]
2019-11-11  3:54   ` [PATCH v3 1/3] bundle: framework for options before bundle file Jeff King
2019-11-11  8:46   ` Johannes Schindelin
2019-11-11  9:00     ` Junio C Hamano
2019-11-12 15:09       ` Johannes Schindelin

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqlfsni1jh.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=robbat2@gentoo.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).