Skip to content

Commit

Permalink
CLI arguments parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
equdevel committed Dec 12, 2022
1 parent 68f8c8e commit 3aede90
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions mod_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import requests
import json
from tqdm import tqdm
import argparse


load_dotenv()
Expand All @@ -26,21 +27,18 @@
if not os.path.isdir(MODS_DIR):
sys.exit(f'\nMODS DIRECTORY NOT FOUND: please check path in .env: {MODS_DIR}')

update = False
if len(sys.argv) == 2:
match sys.argv[1]:
case '--clear-cache':
shutil.rmtree(CACHE_DIR)
os.mkdir(CACHE_DIR)
print('\nClearing cache --> OK')
case '--update':
update = True
case '--help' | '-h':
print('\nUsage:')
print(' --update Update mods if new versions exists')
print(' --clear-cache Clear mods cache on disk')
print(' --help, -h This help')
sys.exit()
parser = argparse.ArgumentParser(
prog='mod_installer',
description='Download mods from mod.io and install them to SnowRunner'
)
parser.add_argument('-c', '--clear-cache', help='clear mods cache on disk', action='store_true')
parser.add_argument('-u', '--update', help='update mods if new versions exist', action='store_true')
args = parser.parse_args()
update = args.update
if args.clear_cache:
shutil.rmtree(CACHE_DIR)
os.mkdir(CACHE_DIR)
print('\nClearing cache --> OK')

headers = {
'Authorization': f'Bearer {ACCESS_TOKEN}',
Expand Down

0 comments on commit 3aede90

Please sign in to comment.