返回提交历史
Modified
g4f/cli/__init__.py
+14
-11
Modified
g4f/cli/client.py
+1
-1
XFEstudio/gpt4free
Improve CLI commands
8e6ddfbf
代码差异
2 个文件
+15
-12
@@ -67,19 +67,22 @@ def run_api_args(args):
67
67
)
68
68
69
69
def main():
70
parser = argparse.ArgumentParser(description="Run gpt4free")
70
parser = argparse.ArgumentParser(description="Run gpt4free", exit_on_error=False)
71
71
subparsers = parser.add_subparsers(dest="mode", help="Mode to run the g4f in.")
72
72
subparsers.add_parser("api", parents=[get_api_parser()], add_help=False)
73
73
subparsers.add_parser("gui", parents=[gui_parser()], add_help=False)
74
74
subparsers.add_parser("client", parents=[get_parser()], add_help=False)
75
75
76
args = parser.parse_args()
77
if args.mode == "api":
78
run_api_args(args)
79
elif args.mode == "gui":
80
run_gui_args(args)
81
elif args.mode == "client":
82
run_client_args(args)
83
else:
84
parser.print_help()
85
exit(1)
76
try:
77
args = parser.parse_args()
78
if args.mode == "api":
79
run_api_args(args)
80
elif args.mode == "gui":
81
run_gui_args(args)
82
elif args.mode == "client":
83
run_client_args(args)
84
else:
85
parser.print_help()
86
exit(1)
87
except argparse.ArgumentError:
88
run_client_args(get_parser().parse_args())
@@ -317,7 +317,7 @@ def run_client_args(args):
317
317
input_text = (" ".join(args.input[rest:])).strip() + input_text
318
318
if media:
319
319
input_text = (media, input_text)
320
if not input_text:
320
if not sys.stdin.isatty() and not input_text:
321
321
input_text = sys.stdin.read().strip()
322
322
if not input_text:
323
323
print("No input provided. Use -h for help.", file=sys.stderr)