Get ID from command line
This commit is contained in:
+12
-3
@@ -20,16 +20,25 @@ import requests
|
||||
from bs4 import BeautifulSoup as bs
|
||||
from os import mkdir
|
||||
from os.path import exists
|
||||
from sys import argv
|
||||
|
||||
### Copyleft message
|
||||
|
||||
print("""Copyleft ilikecats <ilikecats@sdf.org>
|
||||
This program is licensed under the GNU GPL v3-or-later.""")
|
||||
|
||||
### Set this to the comic id.
|
||||
### TODO command line arg
|
||||
### Set this to the comic id or `False` (False means get ID from command line)
|
||||
|
||||
comic_id = "breaking-cat-news"
|
||||
comic_id = False
|
||||
|
||||
### If comic_id is false, get id from command line. If command line has no args,
|
||||
### exit with error.
|
||||
if comic_id == False:
|
||||
if len(argv) == 2:
|
||||
comic_id = argv[1]
|
||||
else:
|
||||
print("Error: Comic ID not provided via command line. Set ID in source or provide ID.")
|
||||
exit(1)
|
||||
|
||||
### Check that comic actually exists (bonus: gocomics does the input
|
||||
### sanitization for you; as long as it exists, you can assume the input is
|
||||
|
||||
Reference in New Issue
Block a user