1 #! /usr/bin/env python3
2 from __future__ import print_function
8 sys.stderr.write("Usage: %s [-0|--null] [-n|--no-newline] [-s|--space] [-w|--width] [width]\n" % sys.argv[0])
13 from getopt import getopt, GetoptError
16 options, arguments = getopt(
17 sys.argv[1:], "0nsw:",
18 ["null", "no-newline", "space", "width="])
27 for option, value in options:
28 if option in ("-h", "--help"):
30 elif option in ("-0", "--null"):
32 elif option in ("-n", "--no-newline"):
34 elif option in ("-s", "--space"):
36 elif option in ("-w", "--width"):
44 elif len(arguments) > 1:
47 width = int(arguments[0])
49 return print0, newline, space, width
51 print0, newline, space, width = get_args()
54 text = sys.stdin.read()
61 text, width - 2*len(space),
62 initial_indent=space, subsequent_indent=space)
64 text = u'\n'.join([line+space for line in text.split(u'\n')])
66 text = u"%s%s%s" % (space, text, space)
68 sys.stdout.write(text)
71 sys.stdout.write('\0')