From 77697be33381a01350d0818ff069469faea2f4ac Mon Sep 17 00:00:00 2001 From: Arran Hobson Sayers Date: Thu, 12 Oct 2023 02:35:11 +0100 Subject: Unify g4f tools into one CLI --- g4f/gui/__init__.py | 2 +- g4f/gui/run.py | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) (limited to 'g4f/gui') diff --git a/g4f/gui/__init__.py b/g4f/gui/__init__.py index 48b78881..a8000e71 100644 --- a/g4f/gui/__init__.py +++ b/g4f/gui/__init__.py @@ -27,4 +27,4 @@ def run_gui(host: str = '0.0.0.0', port: int = 80, debug: bool = False) -> None: print(f"Running on port {config['port']}") app.run(**config) - print(f"Closing port {config['port']}") \ No newline at end of file + print(f"Closing port {config['port']}") diff --git a/g4f/gui/run.py b/g4f/gui/run.py index 731c7cbf..0f94814c 100644 --- a/g4f/gui/run.py +++ b/g4f/gui/run.py @@ -1,18 +1,24 @@ -from g4f.gui import run_gui from argparse import ArgumentParser +from g4f.gui import run_gui -if __name__ == '__main__': - - parser = ArgumentParser(description='Run the GUI') - - parser.add_argument('-host', type=str, default='0.0.0.0', help='hostname') - parser.add_argument('-port', type=int, default=80, help='port') - parser.add_argument('-debug', action='store_true', help='debug mode') - args = parser.parse_args() - port = args.port +def gui_parser(): + parser = ArgumentParser(description="Run the GUI") + parser.add_argument("-host", type=str, default="0.0.0.0", help="hostname") + parser.add_argument("-port", type=int, default=80, help="port") + parser.add_argument("-debug", action="store_true", help="debug mode") + return parser + + +def run_gui_args(args): host = args.host + port = args.port debug = args.debug - - run_gui(host, port, debug) \ No newline at end of file + run_gui(host, port, debug) + + +if __name__ == "__main__": + parser = gui_parser() + args = parser.parse_args() + run_gui_args(args) -- cgit v1.2.3