unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: Daniel Kahn Gillmor <dkg@fifthhorseman.net>,
	Notmuch Mail <notmuch@notmuchmail.org>
Subject: Re: [PATCH v4 1/3] cli: some keyword options can be supplied with no argument
Date: Sat, 23 Dec 2017 10:29:30 -0400	[thread overview]
Message-ID: <87a7y9a56d.fsf@tethera.net> (raw)
In-Reply-To: <20171219164055.20778-2-dkg@fifthhorseman.net>

Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:

>  
> +	bool incremented = false;
>  	if (next == '\0' && next_arg != NULL && ! try->opt_bool) {
>  	    next = ' ';
>  	    value = next_arg;
> +	    incremented = true;
>  	    opt_index ++;
>  	}

Is incremented == true exactly when next == ' ' ? It might be nice to
make that more explicit by setting one based on the other. You could
also use (next == ' ') as your test condition, but I understand that
might not be that obvious to read.

>  
> diff --git a/test/T410-argument-parsing.sh b/test/T410-argument-parsing.sh
> index 192133c5..3f8a78a3 100755
> --- a/test/T410-argument-parsing.sh
> +++ b/test/T410-argument-parsing.sh
> @@ -65,4 +65,28 @@ flags 1
>  EOF
>  test_expect_equal_file EXPECTED OUTPUT
>  
> +test_begin_subtest "test keyword arguments without value"
> +$TEST_DIRECTORY/arg-test --boolkeyword bananas > OUTPUT
> +cat <<EOF > EXPECTED
> +boolkeyword 1
> +positional arg 1 bananas
> +EOF
> +test_expect_equal_file EXPECTED OUTPUT
> +
> +test_begin_subtest "test keyword arguments without value at the end"
> +$TEST_DIRECTORY/arg-test bananas --boolkeyword > OUTPUT
> +cat <<EOF > EXPECTED
> +boolkeyword 1
> +positional arg 1 bananas
> +EOF
> +test_expect_equal_file EXPECTED OUTPUT
> +
> +test_begin_subtest "test keyword arguments without value but with = (should be an error)"
> +$TEST_DIRECTORY/arg-test bananas --boolkeyword= > OUTPUT 2>&1
> +cat <<EOF > EXPECTED
> +Unknown keyword argument "" for option "boolkeyword".
> +Unrecognized option: --boolkeyword=
> +EOF
> +test_expect_equal_file EXPECTED OUTPUT
> +

The thing I'm most nervous about here is the interaction between this
new code and the relatively recent code that permits ' ' as a
seperator. Would you mind adding one or more tests for that case? For
example, that I checked that

         ./notmuch show --format=json --decrypt true $id

continues to work, and that's great, but it seems like something to
check on the argument parsing level, i.e

--keyword␣non-default-value

(pardon my unicode)

  reply	other threads:[~2017-12-23 14:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-19 16:40 [PATCHES v4] Encourage explicit arguments for --decrypt in "show" and "reply" Daniel Kahn Gillmor
2017-12-19 16:40 ` [PATCH v4 1/3] cli: some keyword options can be supplied with no argument Daniel Kahn Gillmor
2017-12-23 14:29   ` David Bremner [this message]
2017-12-25 18:42     ` [PATCH] " David Bremner
2017-12-31 12:58       ` David Bremner
2017-12-29  3:45     ` [PATCH v4 1/3] " Daniel Kahn Gillmor
2017-12-19 16:40 ` [PATCH v4 2/3] cli/show: make --decrypt take a keyword Daniel Kahn Gillmor
2017-12-23 14:39   ` David Bremner
2017-12-29  3:51     ` Daniel Kahn Gillmor
2017-12-19 16:40 ` [PATCH v4 3/3] cli/reply: " Daniel Kahn Gillmor
2017-12-23 14:47   ` David Bremner
2017-12-29  3:28     ` Daniel Kahn Gillmor
2017-12-29 14:30       ` David Bremner
2017-12-29 23:04         ` Daniel Kahn Gillmor
2017-12-30 13:05           ` David Bremner
2017-12-31  0:38             ` Daniel Kahn Gillmor

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: https://notmuchmail.org/

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

  git send-email \
    --in-reply-to=87a7y9a56d.fsf@tethera.net \
    --to=david@tethera.net \
    --cc=dkg@fifthhorseman.net \
    --cc=notmuch@notmuchmail.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://yhetil.org/notmuch.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).