aboutsummaryrefslogtreecommitdiff
path: root/rainbow_parenthesis/__main__.py
blob: 51473c97d81df68ee794a73fd689ea54c36e2e4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
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


def main():
    """Interactive entry point for the program."""
    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='')


if __name__ == '__main__':
    main()