From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Garrit Franke <garrit@slashdev.space>,
git@vger.kernel.org, Taylor Blau <ttaylorr@github.com>
Subject: Re: [PATCH v2] cli: add -v and -h shorthands
Date: Fri, 01 Apr 2022 11:23:39 +0200 [thread overview]
Message-ID: <220401.86y20pnofb.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <xmqqsfqx28dv.fsf@gitster.g>
On Thu, Mar 31 2022, Junio C Hamano wrote:
> Garrit Franke <garrit@slashdev.space> writes:
>
>> On 31.03.22 02:07, Ævar Arnfjörð Bjarmason wrote:
>>
>>> I think this is a good trade-off in this case. I.e. -v and -h are
>>> commonly understood.
>>
>> An interesting observation I just made is that curl [0] uses both
>> "--verbose" and "--version" on the top level [1][2] including
>> shorthands. "-v" corresponds to "verbose", "-V" corresponds to
>> "version.
>>
>> Not that I'm a fan of this clutter, but it's a possible path to go
>> down if we actually needed a second shorthand using this letter.
>
> Do you mean you want to use "-V" for version, instead of the "-v"
> used in the patch, so that "-v" can be left for "--verbose"?
>
> I am not sure consistency with whom we are aiming for anymore with
> that mixed to the proposal X-<.
Maybe you've been convinced to accept -v and -h (I don't care much
either way, honestly), but if not I wonder if this alternate approach
would make everyone in this thread happy (or at least mostly so):
diff --git a/git.c b/git.c
index a25940d72e8..929faa12537 100644
--- a/git.c
+++ b/git.c
@@ -323,7 +323,12 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
exit(list_cmds(cmd));
}
} else {
- fprintf(stderr, _("unknown option: %s\n"), cmd);
+ if (!strcmp(cmd, "-h"))
+ fprintf(stderr, _("unknown option: %s, did you mean --help?\n"), cmd);
+ else if (!strcmp(cmd, "-v"))
+ fprintf(stderr, _("unknown option: %s, did you mean --version?\n"), cmd);
+ else
+ fprintf(stderr, _("unknown option: %s\n"), cmd);
usage(git_usage_string);
}
(Better to pass those as a parameter to the translation, but it's just a
throwaway demo patch for discussion)
I.e. we could help the user in these cases by suggesting that they may
have meant --help or --version, while still leaving the door open to
using these short options for something else.
In git.c we don't use parse-options.c, but that might be a useful
addition for it in general. I.e. to allow an option to define a list of
known alternative (but not understood!) aliases for itself.
So for the cases where we're about to emit an error about -v or whatever
anyway, we could be a bit more helpful and suggest --version, even if we
didn't want to define that as a short option for whatever reason.
next prev parent reply other threads:[~2022-04-01 9:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-30 19:09 [PATCH v2] cli: add -v and -h shorthands Garrit Franke
2022-03-30 21:53 ` Junio C Hamano
2022-03-30 22:50 ` Garrit Franke
2022-03-31 0:07 ` Ævar Arnfjörð Bjarmason
2022-03-31 13:08 ` Garrit Franke
2022-03-31 20:07 ` Junio C Hamano
2022-04-01 9:23 ` Ævar Arnfjörð Bjarmason [this message]
2022-04-01 16:02 ` Junio C Hamano
2022-04-04 7:18 ` Garrit Franke
2022-04-04 16:19 ` Junio C Hamano
2022-03-31 21:27 ` [PATCH v3] " Garrit Franke
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=220401.86y20pnofb.gmgdl@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=garrit@slashdev.space \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ttaylorr@github.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).