Re: parse-options does not recognize "unspecified" behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 16, 2016 at 4:16 PM, Jeff King <peff@xxxxxxxx> wrote:
> On Wed, Mar 16, 2016 at 02:53:17PM -0700, Stefan Beller wrote:
>
>> On Wed, Mar 16, 2016 at 2:44 PM, Jeff King <peff@xxxxxxxx> wrote:
>> > On Wed, Mar 16, 2016 at 05:37:03PM -0400, Eric Sunshine wrote:
>> >
>> >> A much easier solution would be to update OPT_VERBOSE() to understand
>> >> that negative values are "unspecified", and then --verbose would
>> >> (pseudocode):
>> >>
>> >>     if (value < 0)
>> >>         value = 0
>> >>     value++;
>> >>
>> >> and --no-verbose would:
>> >>
>> >>     value = 0
>> >>
>> >> That should be compatible with existing clients of OPT__VERBOSE()
>> >> which initialize the value to 0, and should satisfy Pranit's case; he
>> >> can initialize it to -1, and if it is still -1 when option parsing is
>> >> done, then he knows that neither --verbose nor --no-verbose was seen.
>> >
>> > Yes, that makes much more sense to me. Thanks for the back-story.
>>
>> Is there any command which needs more than one --no-verbose?
>> (as an abuse to stacking --quiet multiple times)?
>
> I'm not sure I understand. "--no-verbose" is just about resetting the
> value. So you might get it multiple times in:
>
>    git commit -v --no-verbose -v --no-verbose
>
> but the caller would not care. Which makes me think I'm misunderstanding
> your question.
>
> You also mention "--quiet", but that is not handled by OPT__VERBOSE, but
> rather by OPT__QUIET. And there I do not think the "-1 is undefined"
> trick works as well there, because presumably "-1" is the same as one
> "--quiet".

The way I understand verbosity is this:
* You can instruct a command to be more verbose if it is supported by
adding more -v
* --no-verbose tells the command to be not verbose, i.e. no additional output.

So my question was, if there is any command, which is verbose by
default, and --no-verbose
would make it "more quiet"? Such a case would be a UX bug, as a user
would rather expect
--quiet instead of --no-verbose IMO. Would such a case ever happen,
that we'd want to give
--no-verbose to decrease the amount said by the command?

IIRC some commands use one integer variable to determine
the amount of output, i.e. --verbose increases that variable, --quiet
decreases it.
What happens for example with

  git commit -v --no-verbose -v -q -q --no-quiet

In case of commit, the quietness and verbosity is done in 2 variables,
so these are orthogonal to each other, there are even no internal checks for
(verbosity > 0 && quietness > 0) at the same time, so it seems to be a valid
command.

In case of a command where this is tracked in one variable,

  git <foo> -v --no-verbose -v -q -q --no-quiet

you'd expect:

  verbosity++ // because of first -v
  verbosity = 0 // because of the reset with --no-verbose
  verbosity++ // because of second -v
  verbosity-- // because of first -q
  verbosity-- // because of second -q
  verbosity = 0 // because of the reset with --no-quiet

Having typed that, I think my comment was not adding value to
the discussion, as --no-{verbose/quiet} would just reset it to 0 no matter
if you track verbosity/quietness in one or two variables internally.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]