File: cli.py

package info (click to toggle)
ptable 0.9.2-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 332 kB
  • sloc: python: 1,651; makefile: 27; sh: 3
file content (24 lines) | stat: -rw-r--r-- 654 bytes parent folder | download | duplicates (3)
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()