summaryrefslogtreecommitdiff
path: root/prettytable/cli.py
blob: 5ab778164c967a463946e11c54f00c654480db36 (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
from __future__ import print_function
import argparse
import sys

from .factory import from_csv
from ._compact import StringIO


def main():
    text_in = sys.stdin.read()
    if text_in:
        print(from_csv(StringIO.StringIO(text_in)))
        return

    parser = argparse.ArgumentParser(description='A simple Python library designed to make it quick and easy to '
                                     'represent tabular data in visually appealing ASCII tables.')
    parser.add_argument('--csv', help='CSV file name')
    args = parser.parse_args()
    with open(args.csv) as fp:
        print(from_csv(fp))


if __name__ == '__main__':
    main()