7 sys.stderr.write("Usage: %s [-0|--null] [-n|--no-newline] [-s|--space] [-w|--width] [width]\n" % sys.argv[0])
12 from getopt import getopt, GetoptError
15 options, arguments = getopt(sys.argv[1:], "0nsw:",
16 ["null", "no-newline", "space", "width="])
25 for option, value in options:
26 if option in ("-h", "--help"):
28 elif option in ("-0", "--null"):
30 elif option in ("-n", "--no-newline"):
32 elif option in ("-s", "--space"):
34 elif option in ("-w", "--width"):
42 elif len(arguments) > 1:
45 width = int(arguments[0])
47 return print0, newline, space, width
49 print0, newline, space, width = get_args()
52 from m_lib.defenc import default_encoding
53 text = sys.stdin.read().decode(default_encoding)
59 text = textwrap.fill(text, width - 2*len(space),
60 initial_indent=space, subsequent_indent=space)
62 text = u'\n'.join([line+space for line in text.split(u'\n')])
64 text = u"%s%s%s" % (space, text, space)
66 sys.stdout.write(text.encode(default_encoding))
69 sys.stdout.write('\0')