from __future__ import print_function

import argparse
import shcol

__all__ = ['main']

def main(cmd_args):
    parser = argparse.ArgumentParser(
        description='Generate columnized output for given string items.',
        version='shcol {}'.format(shcol.__version__)
    )
    parser.add_argument('items', nargs='+', help='the items to columnize')
    parser.add_argument(
        '-s', '--spacing', metavar='N', type=int, default=2,
        help='number of blanks between two columns (default: 2)'
    )
    parser.add_argument(
        '-w', '--width', metavar='N', type=int, default=80,
        help='maximal amount of characters per line (default: 80)'
    )
    parser.add_argument(
        '-S', '--sort', help='sort the items',
        action='store_true', default=False
    )
    print(shcol.columnize(args.items, args.spacing, args.width, args.sort))

from __future__ import print_function

import argparse
import shcol
import sys

__all__ = ['main']

def main(cmd_args):
    parser = argparse.ArgumentParser(
        description='Generate columnized output for given string items.',
        version='shcol {}'.format(shcol.__version__)
    )
    parser.add_argument(
        'items', nargs='*', metavar='item', help='an item to columnize'
    )
    parser.add_argument(
        '-s', '--spacing', metavar='N', type=int, default=2,
        help='number of blanks between two columns (default: 2)'
    )
    parser.add_argument(
        '-w', '--width', metavar='N', type=int, default=80,
        help='maximal amount of characters per line (default: 80)'
    )
    parser.add_argument(
        '-S', '--sort', action='store_true', default=False,
        help='sort the items'
    )
    args = parser.parse_args(cmd_args[1:])
    items = args.items or [line.rstrip('\n') for line in sys.stdin]
    print(shcol.columnize(items, args.spacing, args.width, args.sort))

Read from Stdin when no items are passed.
Read from Stdin when no items are passed.
