Mercurial > hg > TextShaper
changeset 42:1a80204bd562
basic cli
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 25 Aug 2014 19:31:16 -0700 |
parents | 56199789d2a0 |
children | 21b6a9569f21 |
files | setup.py textshaper/onelineit.py |
diffstat | 2 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/setup.py Mon Aug 25 19:22:37 2014 -0700 +++ b/setup.py Mon Aug 25 19:31:16 2014 -0700 @@ -14,6 +14,7 @@ kw['entry_points'] = """ [console_scripts] indent = textshaper.indent:main + onelineit = textshaper.onelineit:main quote = textshaper.quote:main textshaper = textshaper.main:main url2txt = textshaper.url2txt:main
--- 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()