Skip to content

Commit

Permalink
Check the date format and provide usage instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Konovalov committed Feb 23, 2021
1 parent 41ca62a commit 4c06e69
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions dev/release-notes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Usage ./release-notes.py YYYY-MM-DD
# Usage: ./release-notes.py YYYY-MM-DD
#

import sys
Expand All @@ -9,6 +9,8 @@
from github import Github
from datetime import datetime

def usage():
print("Usage: ./release-notes.py YYYY-MM-DD")

def get_prs(repo,startdate):
"""Retrieves data for PRs matching selection criteria and puts them in a dictionary,
Expand Down Expand Up @@ -189,8 +191,16 @@ def main(startdate):
print("Remaining GitHub API capacity", g.rate_limiting, "at", datetime.now().isoformat() )

if __name__ == "__main__":
print("script name is", sys.argv[0])
if (len(sys.argv) != 2): # the argument is the start date in ISO 8601
usage() # to be defined
sys.exit(0) # exit with return value of 0
usage()
sys.exit(0)

try:
datetime.fromisoformat(sys.argv[1])

except:
print("The date is not in ISO8601 format!")
usage()
sys.exit(0)

main(sys.argv[1])

0 comments on commit 4c06e69

Please sign in to comment.