Add argparse

This commit is contained in:
Gabriel Augendre 2018-05-03 14:12:54 +02:00
parent ec447e5e10
commit 3c1669b298

12
main.py
View file

@ -1,3 +1,4 @@
import argparse
import logging import logging
import os import os
import pickle import pickle
@ -12,7 +13,16 @@ from config import (RESOLUTION, MAP_RESOLUTION,
from objects import Snake, Apple from objects import Snake, Apple
from utils import get_score_text, Direction 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__) logger = logging.getLogger(__name__)
pygame.init() pygame.init()