Add argparse
This commit is contained in:
parent
ec447e5e10
commit
3c1669b298
1 changed files with 11 additions and 1 deletions
12
main.py
12
main.py
|
@ -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()
|
||||||
|
|
Loading…
Reference in a new issue