소스 검색

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: