summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2014-05-07 00:03:25 +0200
committerArmin Ronacher <armin.ronacher@active-4.com>2014-05-07 00:03:25 +0200
commit19e9c6dc136ccf17a226e263407876d245dc7ba5 (patch)
treeb542713f9ad6562d8d42da640211d68b742eccd9 /examples
parent38eb59cd00bf81ca13013cc045a66e49ee05d665 (diff)
downloadclick-19e9c6dc136ccf17a226e263407876d245dc7ba5.tar.gz
Updated inout example
Diffstat (limited to 'examples')
-rw-r--r--examples/inout/inout.py31
1 files changed, 24 insertions, 7 deletions
diff --git a/examples/inout/inout.py b/examples/inout/inout.py
index 3d1415a..7b2879e 100644
--- a/examples/inout/inout.py
+++ b/examples/inout/inout.py
@@ -2,12 +2,29 @@ import click
@click.command()
-@click.argument('input', type=click.File('rb'))
+@click.argument('input', type=click.File('rb'), nargs=-1)
@click.argument('output', type=click.File('wb'))
def cli(input, output):
- while True:
- chunk = input.read(1024)
- if not chunk:
- break
- output.write(chunk)
- output.flush()
+ """This script works similar to the unix `cat` command but it writes
+ into a specific file (which could be the standard output as denoted by
+ the ``-`` sign).
+
+ \b
+ Copy stdin to stdout:
+ inout - -
+
+ \b
+ Copy foo.txt and bar.txt to stdout:
+ inout foo.txt bar.txt -
+
+ \b
+ Write stdin into the file foo.txt
+ intout - foo.txt
+ """
+ for f in input:
+ while True:
+ chunk = f.read(1024)
+ if not chunk:
+ break
+ output.write(chunk)
+ output.flush()