XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/gpt4free

Fix Docker slim CLI: catch ArgumentError/SystemExit from mode_parser to handle legacy --port usage

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>

d27ba882
copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
提交于

代码差异

1 个文件 +11 -1
Modified g4f/cli/__init__.py +11 -1
@@ -301,7 +301,17 @@ def main():
301 301 mode_parser = ArgumentParser(description="Select mode to run g4f in.", exit_on_error=False)
302 302 mode_parser.add_argument("mode", nargs="?", choices=["api", "gui", "client", "mcp", "auth"], default="api", help="Mode to run g4f in (default: api).")
303 303
304 args, remaining = mode_parser.parse_known_args(remaining)
304 # Preserve original remaining so the API parser gets all args if mode
305 # detection fails (e.g. `python -m g4f --port 8080` without a mode prefix).
306 original_remaining = remaining
307 try:
308 args, remaining = mode_parser.parse_known_args(remaining)
309 except (argparse.ArgumentError, SystemExit):
310 # If mode parsing fails (e.g. a port number or unknown flag appears
311 # before the mode positional), fall back to API mode and restore the
312 # original argument list so the API parser can handle them.
313 args = argparse.Namespace(mode="api")
314 remaining = original_remaining
305 315 try:
306 316 if args.mode == "auth":
307 317 parser = get_auth_parser()