From: Jani Nikula <jani@nikula.org>
To: notmuch@notmuchmail.org
Subject: [PATCH 8/9] test: add boolean argument to arg-test
Date: Tue, 19 Sep 2017 23:39:28 +0300 [thread overview]
Message-ID: <18b244570331278f0064b41a1e4f1b713781e7e2.1505853159.git.jani@nikula.org> (raw)
In-Reply-To: <cover.1505853159.git.jani@nikula.org>
In-Reply-To: <cover.1505853159.git.jani@nikula.org>
Surprisingly it's not there.
---
test/T410-argument-parsing.sh | 3 ++-
test/arg-test.c | 5 +++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/test/T410-argument-parsing.sh b/test/T410-argument-parsing.sh
index fad134e305c5..4505c58301ea 100755
--- a/test/T410-argument-parsing.sh
+++ b/test/T410-argument-parsing.sh
@@ -3,8 +3,9 @@ test_description="argument parsing"
. ./test-lib.sh || exit 1
test_begin_subtest "sanity check"
-$TEST_DIRECTORY/arg-test pos1 --keyword=one --string=foo pos2 --int=7 --flag=one --flag=three > OUTPUT
+$TEST_DIRECTORY/arg-test pos1 --keyword=one --boolean --string=foo pos2 --int=7 --flag=one --flag=three > OUTPUT
cat <<EOF > EXPECTED
+boolean 1
keyword 1
flags 5
int 7
diff --git a/test/arg-test.c b/test/arg-test.c
index 736686ded2c0..2f839c992c56 100644
--- a/test/arg-test.c
+++ b/test/arg-test.c
@@ -12,8 +12,10 @@ int main(int argc, char **argv){
char *pos_arg1=NULL;
char *pos_arg2=NULL;
char *string_val=NULL;
+ notmuch_bool_t bool_val = FALSE;
notmuch_opt_desc_t options[] = {
+ { NOTMUCH_OPT_BOOLEAN, &bool_val, "boolean", 'b', 0},
{ NOTMUCH_OPT_KEYWORD, &kw_val, "keyword", 'k',
(notmuch_keyword_t []){ { "one", 1 },
{ "two", 2 },
@@ -34,6 +36,9 @@ int main(int argc, char **argv){
if (opt_index < 0)
return 1;
+ if (bool_val)
+ printf("boolean %d\n", bool_val);
+
if (kw_val)
printf("keyword %d\n", kw_val);
--
2.11.0
next prev parent reply other threads:[~2017-09-19 20:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-19 20:39 [PATCH 0/9] argument parsing fixes and improvements Jani Nikula
2017-09-19 20:39 ` [PATCH 1/9] hex-xcode: use notmuch_bool_t for boolean arguments Jani Nikula
2017-09-19 20:39 ` [PATCH 2/9] cli: use notmuch_bool_t for boolean argument in show Jani Nikula
2017-09-19 20:39 ` [PATCH 3/9] cli: refactor boolean argument processing Jani Nikula
2017-09-19 20:39 ` [PATCH 4/9] cli: change while to for in keyword " Jani Nikula
2017-09-19 20:39 ` [PATCH 5/9] cli: reduce indent " Jani Nikula
2017-09-19 20:39 ` [PATCH 6/9] cli: add support for --no- prefixed boolean and keyword flag arguments Jani Nikula
2017-09-19 20:39 ` [PATCH 7/9] cli: use the negating boolean support for new and insert --no-hooks Jani Nikula
2017-09-19 20:39 ` Jani Nikula [this message]
2017-09-19 20:39 ` [PATCH 9/9] test: expand argument parsing sanity checks Jani Nikula
2017-09-19 21:43 ` [PATCH 0/9] argument parsing fixes and improvements Daniel Kahn Gillmor
2017-09-20 9:16 ` Jani Nikula
2017-09-20 13:21 ` Daniel Kahn Gillmor
2017-09-21 17:07 ` Jani Nikula
2017-09-21 18:52 ` Daniel Kahn Gillmor
2017-09-25 11:34 ` David Bremner
2017-09-25 13:02 ` Daniel Kahn Gillmor
2017-09-25 20:57 ` David Bremner
2017-09-30 9:40 ` Jani Nikula
2017-09-30 21:37 ` Jani Nikula
2017-10-01 11:11 ` David Bremner
2017-10-01 20:57 ` Jani Nikula
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=18b244570331278f0064b41a1e4f1b713781e7e2.1505853159.git.jani@nikula.org \
--to=jani@nikula.org \
--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).