aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHåkon Solbjørg <hlsolbjorg@gmail.com>2019-04-01 22:43:27 +0200
committerHåkon Solbjørg <hlsolbjorg@gmail.com>2019-04-02 19:56:08 +0200
commit98e35a3fa02b598d104cde9aafb877006d8065b3 (patch)
treedcee95cb0847b81a33051683eacb7a5e572bdddd
parent8b2ce44bbe1456088f72d677a48cb230cf0991e1 (diff)
feat: Add argparse to allow for specifying which labler function to run 🤙
-rw-r--r--cables.py2
-rw-r--r--main.py17
-rw-r--r--switches.py1
3 files changed, 19 insertions, 1 deletions
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)