Skip to content

Commit 5e68213

Browse files
committed
Fix parser of positional args with
1 parent 2e688c8 commit 5e68213

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
55

66
[tool.poetry]
77
name = "proper-cli"
8-
version = "1.4"
8+
version = "1.4.1"
99
description = "Replace your HTML templates with Python server-Side components"
1010
authors = ["Juan-Pablo Scaletti <[email protected]>"]
1111
license = "MIT"

src/proper_cli/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def parse_args(
2626
# Split the "key=arg" arguments
2727
largs = []
2828
for arg in cliargs:
29-
if "=" in arg:
30-
key, arg = arg.split("=")
29+
if "-" == arg[0] and "=" in arg:
30+
key, arg = arg.split("=", 1)
3131
largs.append(key)
3232
largs.append(arg)
3333

tests/test_parser.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,21 @@
22

33

44
def test_parse_args():
5-
result = parse_args(["abc", "xy", "-w=3", "--foo", "bar", "-narf=zort"])
6-
expected = (["abc", "xy"], {"foo": "bar", "w": "3", "narf": "zort"})
5+
result = parse_args([
6+
"abc",
7+
"xy",
8+
"meh:lorem=ipsum",
9+
"-w=3",
10+
"--foo",
11+
"bar",
12+
"-narf=zort",
13+
"qwer=ty"
14+
])
15+
expected = (
16+
["abc", "xy", "meh:lorem=ipsum"],
17+
{"foo": "bar", "w": "3", "narf": ["zort", "qwer=ty"]},
18+
)
19+
print(result)
720
assert result == expected
821

922

0 commit comments

Comments
 (0)