Mercurial > hg > TextShaper
diff textshaper/onelineit.py @ 42:1a80204bd562
basic cli
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 25 Aug 2014 19:31:16 -0700 |
parents | 56199789d2a0 |
children | 21b6a9569f21 |
line wrap: on
line diff
--- a/textshaper/onelineit.py Mon Aug 25 19:22:37 2014 -0700 +++ b/textshaper/onelineit.py Mon Aug 25 19:31:16 2014 -0700 @@ -1,6 +1,14 @@ #!/usr/bin/env python +""" +make a string one line +""" + +import sys + def onelineit(string): + """make a string one line""" + string = string.split('\n') string = [ i.strip() or '\n' for i in string ] string = ' '.join(string) @@ -9,6 +17,9 @@ return '\n\n'.join(string) +def main(args=sys.argv[1:]): + """CLI""" + print (onelineit(sys.stdin.read())) + if __name__ == '__main__': - import sys - print onelineit(sys.stdin.read()) + main()