From dfeab3cbdb6e3e261a55524b4ef7690621aa27d7 Mon Sep 17 00:00:00 2001 From: pritchyspritch Date: Fri, 3 May 2024 15:06:14 +0100 Subject: [PATCH] Make args available --- README.md | 4 ++-- produce_risk_tracker.py | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 53ffbfe..9f98001 100644 --- a/README.md +++ b/README.md @@ -123,8 +123,8 @@ The output it provides comes from your risks.json that threagile produces, and p # TODO / Roadmap -- [ ] example GitHub Action to watch file -- [ ] use params for python +- [x] example GitHub Action to watch file +- [x] use params for python - [ ] produce example sections for common design patterns - [ ] improve readme - [ ] automate more of the yaml building beyond what threagile can do \ No newline at end of file diff --git a/produce_risk_tracker.py b/produce_risk_tracker.py index 95cdf6d..fe4dac0 100644 --- a/produce_risk_tracker.py +++ b/produce_risk_tracker.py @@ -1,5 +1,6 @@ import json import datetime +import argparse def print_yaml(risk_dict): @@ -11,8 +12,8 @@ def print_yaml(risk_dict): print(f" checked_by: ") -def read_risks_json(): - file = open('risks.json') +def read_risks_json(file_path): + file = open(file_path) data = json.load(file) date_today_obj = datetime.datetime.now() @@ -31,4 +32,10 @@ def read_risks_json(): if __name__ == '__main__': - read_risks_json() \ No newline at end of file + parser = argparse.ArgumentParser(description='Process some integers.') + + parser.add_argument('--file', nargs='?', default='risks.json', help='The file path for you risks json file') + + args = parser.parse_args() + + read_risks_json(args.file) \ No newline at end of file