Use argparse to convert continue_from to int

This commit is contained in:
Ryszard Knop 2021-10-03 13:28:24 +02:00
parent f86044050f
commit 8159244f8d

View File

@ -291,20 +291,12 @@ if __name__ == "__main__":
parser.add_argument("entries", help="path to the game jam entries.json file") parser.add_argument("entries", help="path to the game jam entries.json file")
parser.add_argument("--api-key", metavar="key", required=True, help="itch.io API key from https://itch.io/user/settings/api-keys") parser.add_argument("--api-key", metavar="key", required=True, help="itch.io API key from https://itch.io/user/settings/api-keys")
parser.add_argument("--download-to", metavar="path", help="directory to save results into (default: current dir)") parser.add_argument("--download-to", metavar="path", help="directory to save results into (default: current dir)")
parser.add_argument("--continue-from", metavar="id", help="skip all entries until the provided entry ID is found") parser.add_argument("--continue-from", metavar="id", type=int, help="skip all entries until the provided entry ID is found")
args = parser.parse_args() args = parser.parse_args()
continue_id = args.continue_from
if continue_id is not None:
try:
continue_id = int(continue_id)
except:
print("ID to continue from must be an integer.")
exit(1)
download_to = os.getcwd() download_to = os.getcwd()
if args.download_to is not None: if args.download_to is not None:
download_to = os.path.normpath(args.download_to) download_to = os.path.normpath(args.download_to)
os.makedirs(download_to) os.makedirs(download_to)
download_jam(args.entries, download_to, args.api_key, continue_from=continue_id) download_jam(args.entries, download_to, args.api_key, continue_from=args.continue_from)