From 6f5f0305398ae614fee877223dd640d9d4a4e249 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 8 Nov 2019 16:28:04 +0000 Subject: [PATCH] Fix #6 --- confutils/cli_parser.nim | 3 ++- tests/issue_6.nim | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/issue_6.nim diff --git a/confutils/cli_parser.nim b/confutils/cli_parser.nim index 3bf2da5..0cf2a99 100644 --- a/confutils/cli_parser.nim +++ b/confutils/cli_parser.nim @@ -114,7 +114,8 @@ proc next*(p: var OptParser) = inc(i) while i < p.cmds[p.idx].len and p.cmds[p.idx][i] in {'\t', ' '}: inc(i) # if we're at the end, use the next command line option: - if i >= p.cmds[p.idx].len and p.idx < p.cmds.len and p.allowWhitespaceAfterColon: + if p.allowWhitespaceAfterColon and i >= p.cmds[p.idx].len and + p.idx + 1 < p.cmds.len and p.cmds[p.idx + 1][0] != '-': inc p.idx i = 0 if p.idx < p.cmds.len: diff --git a/tests/issue_6.nim b/tests/issue_6.nim new file mode 100644 index 0000000..bf443f7 --- /dev/null +++ b/tests/issue_6.nim @@ -0,0 +1,7 @@ +import confutils + +# TODO add test cases for https://github.com/status-im/nim-confutils/issues/6 +cli do (arg1: string = "", arg2: string = ""): + echo "arg1: ", arg1 + echo "arg2: ", arg2 +