Skip to content

The only downloader you need. 下载器的集大成者。

feat(cli): 裸运行 ghd 时显示帮助

XiaoYouChR76137750e1ac
diff --git a/app/cli.py b/app/cli.py
index bc680b6d..d66aec57 100644
--- a/app/cli.py
+++ b/app/cli.py
@@ -158,7 +158,7 @@ class Cli:
reply(Reply("", 0))
return
try:
- args = self._parser.parse_args(argv[1:])
+ args = self._parser.parse_args(argv[1:] or ["--help"])
except TextRequested as text:
reply(Reply(str(text).rstrip("\n"), 0))
return
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 9aa55219..ec3d14be 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -100,6 +100,15 @@ def test_help_lists_commands(cli):
assert not reply.output.endswith("\n")
+def test_without_command_replies_help(cli):
+ replies = []
+
+ cli.run(Invocation(["ghd"], ".", replies.append))
+ cli.run(Invocation(["ghd", "--help"], ".", replies.append))
+
+ bare, help = replies
+ assert bare == help
+
def test_version_replies_running_version(cli):
replies = []
@@ -110,6 +119,7 @@ def test_version_replies_running_version(cli):
assert reply.exitCode == 0
assert reply.output == f"ghd (Ghost Downloader) {VERSION}"
+
async def test_wait_returns_when_task_completes(cli, engine):
task = buildTask("complete")
engine.taskService.add(task, autoStart=False)