From: Andreas Ericsson <ae@op5.se>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Jeff King" <peff@peff.net>, "Kristian Høgsberg" <krh@redhat.com>,
"Pierre Habouzit" <madcoder@debian.org>,
git@vger.kernel.org
Subject: Re: [RFH] convert shortlog to use parse_options
Date: Fri, 14 Dec 2007 09:33:55 +0100 [thread overview]
Message-ID: <47623FF3.1050601@op5.se> (raw)
In-Reply-To: <7vir31vmsn.fsf@gitster.siamese.dyndns.org>
Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
>> I agree. I am already a little bit uncomfortable with the "--abbrev 10"
>> won't work but "--foo 10" will, because it requires that the user
>> remember which arguments are optional and which are required. But
>> switching it to "--abbrev 10 works, but --abbrev $foo does not, unless
>> of course $foo is an integer, in which case you must use --abbrev=$foo"
>> is just a little bit too DWIM. E.g., if you are scripting, it's just one
>> more source of error (if I have $foo, how must I write --abbrev $foo for
>> it to ensure that I _don't_ trigger the optional argument?).
>
> Oh, there is no question that scripted callers need a way to safely
> disambiguate, and be able to call "git cmd" with always the default
> abbreviation for whatever $foo it gets from the user unambiguously.
>
> I do not disagree with that.
>
> But that is different from making it harder for end users (not scripters
> but command line users).
>
> Again, I am not saying that my suggested alternative is superiour; I
> just threw it out to as an example of a different approach to achieve
> disambiguation than the "some flags must have its parameter stuck with
> it, some don't" behaviour, which will surely be confusing to the command
> line end users.
>
> To contrast the two, with Pierre's, if you want $n-digit abbreviations
> and $cnt-lines of output in your script, your script would say:
>
> git cmd --abbrev=$n -n $cnt $foo
>
> because you as a script writer are required to know --abbrev is such a
> magic flag that take optional parameter and cannot be fed as two options
> (you can also write "-n=$cnt", but I am talking about --abbrev part).
>
> If you are accepting the default abbreviation, on the other hand:
>
> git cmd --abbrev -n $cnt $foo
>
> which looks nice. The latter needs to be written in a funky way:
>
> git cmd --abbrev= $foo
>
> if we take "empty parameter to a flag that take optional parameter means
> use the default setting"; we could introduce a magic 'default' token to
> read it slightly better:
>
> git cmd --abbrev=default $foo
>
> but that does not change the fact that it makes it harder for
> scripters. I do not disagree with that.
>
> The command line end users, who want to do the same, but has a bit more
> concrete than unknown $n, $cnt, or $foo, can do
>
> git cmd --abbrev HEAD~4
>
> in either approach. However, with Pierre's, the command line end users
> can say either:
>
> git cmd --abbrev=10 -n=4
> git cmd --abbrev=10 -n 4
> git cmd --abbrev=10 -n4
>
> but they cannot say:
>
> git cmd --abbrev 10 -n 4
>
> They need to learn the difference between --abbrev and -n, because you
> avoid DWIMmery for the sake of script writers. I have a slight
> suspicion that it is backwards.
>
> If there is _no_ existing users and previous versions of git, one
> plausible alternative that would be much cleaner than anything we
> discussed so far would be to always require '-n=4' (or "-n4") form and
> never accept "-n 4", even for a flag that takes mandatory parameter.
> Then there is no room for confusion. Users (both command line end users
> and script writers) need to learn only one rule: flag parameters are
> always with the flag, not given as two words.
>
> I really wish the world were that simple, but I do no think that would
> fly well with the existing users' fingers.
I think you're right in that last sentence. It would also be terribly
inconsistent with the other 3000 or so command-line programs one has
in ones path.
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
next prev parent reply other threads:[~2007-12-14 8:34 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-13 5:52 [RFH] convert shortlog to use parse_options Jeff King
2007-12-13 9:06 ` Pierre Habouzit
2007-12-13 9:10 ` Jeff King
2007-12-13 9:35 ` Pierre Habouzit
2007-12-13 10:26 ` [PATCH 1/2] parseopt: Enforce the use of the sticked form for optional arguments Pierre Habouzit
2007-12-13 10:27 ` [PATCH 2/2] parseopt: Add a gitcli(5) man page Pierre Habouzit
2007-12-13 11:04 ` Wincent Colaiuta
2007-12-13 13:56 ` Pierre Habouzit
2007-12-17 7:28 ` [PATCH] (squashme) gitcli documentation fixups Junio C Hamano
2007-12-17 8:51 ` Pierre Habouzit
2007-12-17 8:57 ` Pierre Habouzit
2007-12-17 7:28 ` [PATCH] builtin-tag: fix fallouts from recent parsopt restriction Junio C Hamano
2007-12-17 9:07 ` Pierre Habouzit
2007-12-17 10:53 ` Junio C Hamano
2007-12-17 10:58 ` Pierre Habouzit
2007-12-17 11:21 ` Junio C Hamano
2007-12-17 12:33 ` Pierre Habouzit
2007-12-17 19:52 ` Junio C Hamano
2007-12-17 20:31 ` Jeff King
2007-12-17 20:42 ` Pierre Habouzit
2007-12-17 21:01 ` Pierre Habouzit
2007-12-17 23:07 ` Jeff King
2007-12-17 23:14 ` Pierre Habouzit
2007-12-17 20:42 ` Junio C Hamano
2007-12-17 20:53 ` Jeff King
2007-12-17 21:24 ` Pierre Habouzit
2007-12-17 21:11 ` Pierre Habouzit
2007-12-17 11:13 ` Junio C Hamano
2007-12-17 11:56 ` Pierre Habouzit
2007-12-17 11:59 ` Pierre Habouzit
2007-12-13 17:40 ` [RFH] convert shortlog to use parse_options Junio C Hamano
2007-12-13 18:03 ` Pierre Habouzit
2007-12-13 18:07 ` Pierre Habouzit
2007-12-13 19:49 ` Junio C Hamano
2007-12-13 18:28 ` Kristian Høgsberg
2007-12-13 18:47 ` Kristian Høgsberg
2007-12-13 20:46 ` Junio C Hamano
2007-12-14 4:08 ` Jeff King
2007-12-14 5:59 ` Junio C Hamano
2007-12-14 8:33 ` Andreas Ericsson [this message]
2007-12-14 8:39 ` Pierre Habouzit
2007-12-14 20:34 ` Junio C Hamano
2007-12-15 11:03 ` Pierre Habouzit
2007-12-17 7:27 ` Junio C Hamano
2007-12-17 7:36 ` Andreas Ericsson
2007-12-17 7:59 ` Junio C Hamano
2007-12-17 9:38 ` Andreas Ericsson
2007-12-17 16:21 ` Kristian Høgsberg
2007-12-13 19:31 ` Junio C Hamano
2007-12-13 20:53 ` Pierre Habouzit
2007-12-13 9:29 ` 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=47623FF3.1050601@op5.se \
--to=ae@op5.se \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=krh@redhat.com \
--cc=madcoder@debian.org \
--cc=peff@peff.net \
/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).