Skip to content

Commit

Permalink
Merge pull request #108 from pieterdeschepper/master
Browse files Browse the repository at this point in the history
Make sure stdin can also be used
  • Loading branch information
tushuhei authored Jan 16, 2020
2 parents a6124df + e72f87d commit 535c92f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions budou/budou.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""Budou: an automatic organizer tool for beautiful line breaking in CJK
Usage:
budou [--segmenter=<seg>] [--language=<lang>] [--classname=<class>] [--inlinestyle] [--wbr] <source>
budou [--segmenter=<seg>] [--language=<lang>] [--classname=<class>] [--inlinestyle] [--wbr] [<source>]
budou -h | --help
budou -v | --version
Expand Down Expand Up @@ -58,9 +58,17 @@ def main():
if args['--version']:
print(__version__)
sys.exit()

if args['<source>']:
source = args['<source>']
elif not sys.stdin.isatty():
source = sys.stdin.read()
else:
print(__doc__.split("\n\n")[1])
sys.exit()

result = parse(
args['<source>'],
source,
segmenter=args['--segmenter'],
language=args['--language'],
classname=args['--classname'],
Expand Down

0 comments on commit 535c92f

Please sign in to comment.