Skip to content

Commit

Permalink
updated cli
Browse files Browse the repository at this point in the history
  • Loading branch information
smythi93 committed Sep 22, 2023
1 parent 1888db0 commit 678e4d9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/sflkit/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import argparse
import json
import logging
import os
import sys
from typing import Any

import sflkit
Expand All @@ -25,7 +27,18 @@ def default(self, o: Any) -> Any:
return super().default(o)


def main(args):
def main(*args: str, stdout=sys.stdout, stderr=sys.stderr):
if "-O" in sys.argv:
sys.argv.remove("-O")
os.execl(sys.executable, sys.executable, "-O", *sys.argv)

if stdout is not None:
sys.stdout = stdout
if stderr is not None:
sys.stderr = stderr

args = parse_args(args or sys.argv[1:])

if args.debug:
LOGGER.setLevel(logging.DEBUG)
else:
Expand Down Expand Up @@ -117,4 +130,8 @@ def parse_args(args=None, namespace=None):


if __name__ == "__main__":
main(parse_args())
if "-O" in sys.argv:
sys.argv.remove("-O")
os.execl(sys.executable, sys.executable, "-O", *sys.argv)
else:
main()

0 comments on commit 678e4d9

Please sign in to comment.