浏览代码

Display error message if there is no arg

jherve 1 月之前
父节点
当前提交
62f844d9ba
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      pc_backup/cli.py

+ 5 - 1
pc_backup/cli.py

@@ -11,7 +11,11 @@ class CliArguments:
     @staticmethod
     def read_command(parser):
         args = parser.parse_args()
-        return args.command(args)
+
+        if hasattr(args, "command"):
+            return args.command(args)
+        else:
+            return parser.error("You should call at least one of the commands")
 
     @staticmethod
     def new() -> argparse.ArgumentParser: