From 3c1669b2985409823560d7d8e6ad352b26b1d6bc Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Thu, 3 May 2018 14:12:54 +0200 Subject: [PATCH] Add argparse --- main.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 1a01c2d..e88b8ef 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +import argparse import logging import os import pickle @@ -12,7 +13,16 @@ from config import (RESOLUTION, MAP_RESOLUTION, from objects import Snake, Apple from utils import get_score_text, Direction -logging.basicConfig(level=logging.DEBUG) + +parser = argparse.ArgumentParser() +parser.add_argument('-v', '--verbose', help='Show debug logs', action='store_true') +args = parser.parse_args() + +level = logging.INFO +if args.verbose: + level = logging.DEBUG + +logging.basicConfig(level=level) logger = logging.getLogger(__name__) pygame.init()