Example argparse

This commit is contained in:
hppeng 2022-06-25 05:44:24 -07:00
parent d749c86d89
commit b175bdbcc7

View file

@ -7,13 +7,18 @@ Usage: python get.py [url or command] [outfile rel path]
Relevant page: https://docs.wynncraft.com/
"""
import requests
import argparse
import json
import numpy as np
import sys
#req can either be a link to an API page OR a preset default
req, outfile = sys.argv[1], sys.argv[2]
import numpy as np
import requests
parser = argparse.ArgumentParser(description="Pull data from wynn API.")
parser.add_argument('target', help='an API page, or preset [items, ings, recipes, terrs, maploc]')
parser.add_argument('outfile', help='output file to dump results into')
args = parser.parse_args()
req, outfile = args.target, args.outfile
CURR_WYNN_VERS = 2.0
@ -57,4 +62,4 @@ else:
response['version'] = CURR_WYNN_VERS
json.dump(response, open(outfile, "w+"))
json.dump(response, open(outfile, "w+"))