From 98e35a3fa02b598d104cde9aafb877006d8065b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Solbj=C3=B8rg?= Date: Mon, 1 Apr 2019 22:43:27 +0200 Subject: =?UTF-8?q?feat:=20Add=20argparse=20to=20allow=20for=20specifying?= =?UTF-8?q?=20which=20labler=20function=20to=20run=20=F0=9F=A4=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cables.py | 2 ++ main.py | 17 ++++++++++++++++- switches.py | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 cables.py diff --git a/cables.py b/cables.py new file mode 100644 index 0000000..f32d7bc --- /dev/null +++ b/cables.py @@ -0,0 +1,2 @@ +def make_cable_labels(): + print("Generating labels for cables") diff --git a/main.py b/main.py index 49f717b..ca23f58 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,20 @@ +import argparse +import sys + from switches import make_switch_labels +from cables import make_cable_labels +parser = argparse.ArgumentParser("Label generator script 2000") +parser.add_argument("labler", type=str, + help="The label function to run. Either [c]ables or [s]witches.") if __name__ == "__main__": - make_switch_labels() + args = parser.parse_args() + + if args.labler[0] == "c": + make_cable_labels() + elif args.labler[0] == "s": + make_switch_labels() + else: + parser.print_help() + sys.exit("Invalid labler operation.") diff --git a/switches.py b/switches.py index dbc7ece..d6c80a7 100644 --- a/switches.py +++ b/switches.py @@ -40,6 +40,7 @@ def write_html_to_file(html, outfile="switch_labels.html"): def make_switch_labels(): + print("Generating labels for switches") switches = fetch_gondul_switches() labels = generate_labels(switches) write_html_to_file(labels) -- cgit v1.2.3