From 7ab9bd207df0a1318880cf3789346cf3f475be61 Mon Sep 17 00:00:00 2001 From: Mark McIntyre Date: Mon, 26 Apr 2021 11:16:36 -0400 Subject: [PATCH] added custom start-date to quarantine-day-counter --- quarantine-day-counter | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/quarantine-day-counter b/quarantine-day-counter index 8d9f561..62f4d0c 100755 --- a/quarantine-day-counter +++ b/quarantine-day-counter @@ -19,6 +19,11 @@ quarantine_start_date = "13 Mar 2020" def parse_args(): argp = argparse.ArgumentParser() + argp.add_argument( + '-s', '--start-date', + default=quarantine_start_date, + help="Different start date than the original (%(default)s)" + ) return argp.parse_args() def quarantine_days(quarantine_start_date=quarantine_start_date): @@ -27,13 +32,14 @@ def quarantine_days(quarantine_start_date=quarantine_start_date): if __name__ == "__main__": - # args = parse_args() + args = parse_args() + try: - start_date_message = f"\nQuarantine Start Date: {color.yellow(quarantine_start_date)}" - quarantine_days_message = f"Quarantine Days: {color.red(quarantine_days(quarantine_start_date))}" + start_date_message = f"\nQuarantine Start Date: {color.yellow(args.start_date)}" + quarantine_days_message = f"Quarantine Days: {color.red(quarantine_days(args.start_date))}" except NameError: - start_date_message = f"\nQuarantine Start Date: {quarantine_start_date}" - quarantine_days_message = f"Quarantine Days: {quarantine_days(quarantine_start_date)}" + start_date_message = f"\nQuarantine Start Date: {args.start_date}" + quarantine_days_message = f"Quarantine Days: {quarantine_days(args.start_date)}" print(start_date_message) print(quarantine_days_message)