aboutsummaryrefslogtreecommitdiff
path: root/rainbow_parenthesis/__main__.py
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-07-12 23:14:23 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-07-12 23:14:23 +0200
commitf333cae22e1d19119b1aa9ee9d30daa21243d1d8 (patch)
tree28cbef38210abb01284a54041250342f556bd8e9 /rainbow_parenthesis/__main__.py
parentRemove black from the pool of colors. (diff)
downloadrainbow-parenthesis-f333cae22e1d19119b1aa9ee9d30daa21243d1d8.tar.gz
rainbow-parenthesis-f333cae22e1d19119b1aa9ee9d30daa21243d1d8.tar.xz
Move project to a proper module layout.
Diffstat (limited to 'rainbow_parenthesis/__main__.py')
-rw-r--r--rainbow_parenthesis/__main__.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/rainbow_parenthesis/__main__.py b/rainbow_parenthesis/__main__.py
new file mode 100644
index 0000000..251731a
--- /dev/null
+++ b/rainbow_parenthesis/__main__.py
@@ -0,0 +1,23 @@
+"""
+Entry point for rainbow parenthesis.
+
+Reads a string from stdin, and outputs it to stdout with all
+parenthesis prettily colored.
+"""
+
+from . import colorize, Colored
+from . import term
+import argparse
+
+parser = argparse.ArgumentParser(prog='rainbow')
+parser.add_argument('input', type=argparse.FileType('r'),
+ nargs='?', default='-')
+args = parser.parse_args()
+
+
+for item in colorize(args.input):
+ match item:
+ case Colored():
+ print(term.colorize(item), end='')
+ case s:
+ print(s, end='')