Skip to content

Commit

Permalink
ui/main.py: pass sys.argv to mainNoExit func
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Jan 3, 2025
1 parent 88a4fa6 commit 5cf7dad
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pyglossary/ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ class MainPrepareResult:
# TODO:
# PLR0911 Too many return statements (7 > 6)
# PLR0915 Too many statements (56 > 50)
def mainPrepare() -> tuple[bool, MainPrepareResult | None]:
def mainPrepare(argv: list[str]) -> tuple[bool, MainPrepareResult | None]:
global log

uiBase = UIBase()
uiBase.loadConfig()
config = uiBase.config

parser = argparse.ArgumentParser(
prog=sys.argv[0],
prog=argv[0],
add_help=False,
# allow_abbrev=False,
)
Expand All @@ -136,7 +136,7 @@ def mainPrepare() -> tuple[bool, MainPrepareResult | None]:

# _______________________________

args = parser.parse_args()
args = parser.parse_args(argv)

# parser.conflict_handler == "error"

Expand Down Expand Up @@ -266,8 +266,8 @@ def mainPrepare() -> tuple[bool, MainPrepareResult | None]:
)


def mainNoExit() -> bool: # noqa: PLR0912
ok, res = mainPrepare()
def mainNoExit(argv: list[str]) -> bool: # noqa: PLR0912
ok, res = mainPrepare(argv)
if not ok:
return False
if res is None: # --version or --help
Expand Down Expand Up @@ -299,4 +299,4 @@ def mainNoExit() -> bool: # noqa: PLR0912


def main() -> None:
sys.exit(int(not mainNoExit()))
sys.exit(int(not mainNoExit(sys.argv)))

0 comments on commit 5cf7dad

Please sign in to comment.