Skip to content

Commit d5c7a45

Browse files
committed
CLI: fix arguments handling
1 parent d505f51 commit d5c7a45

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

CHANGELOG

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ History:
33
<see Git checking messages for history>
44

55
8.0.2 2023/xx/xx
6-
-
6+
- CLI: fixed arguments handling
77

88
8.0.1 2023/04/09
99
- MSS: ensure --with-cursor, and with_cursor argument & attribute, are simple NOOP on platforms not supporting the feature

mss/__main__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
"""
55
import os.path
66
from argparse import ArgumentParser
7-
from typing import List
87

98
from . import __version__
109
from .exception import ScreenShotError
1110
from .factory import mss
1211
from .tools import to_png
1312

1413

15-
def main(args: List[str], /) -> int:
14+
def main(*args: str) -> int:
1615
"""Main logic."""
1716

1817
cli_args = ArgumentParser()
@@ -83,4 +82,4 @@ def main(args: List[str], /) -> int:
8382
if __name__ == "__main__": # pragma: nocover
8483
import sys
8584

86-
sys.exit(main(sys.argv[1:]))
85+
sys.exit(main(*sys.argv[1:]))

mss/tests/test_implementation.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,16 @@ def test_entry_point(with_cursor: bool, capsys):
8787
def main(*args: str, ret: int = 0) -> None:
8888
if with_cursor:
8989
args = args + ("--with-cursor",)
90-
assert entry_point(args) == ret
90+
assert entry_point(*args) == ret
91+
92+
# No arguments
93+
main()
94+
out, _ = capsys.readouterr()
95+
for mon, line in enumerate(out.splitlines(), 1):
96+
filename = f"monitor-{mon}.png"
97+
assert line.endswith(filename)
98+
assert os.path.isfile(filename)
99+
os.remove(filename)
91100

92101
for opt in ("-m", "--monitor"):
93102
main(opt, "1")
@@ -147,7 +156,7 @@ def test_entry_point_error(quiet: bool, capsys):
147156
def main(*args: str) -> int:
148157
if quiet:
149158
args = args + ("--quiet",)
150-
return entry_point(args)
159+
return entry_point(*args)
151160

152161
if quiet:
153162
assert main() == 1

0 commit comments

Comments
 (0)