MCPcopy
hub / github.com/pallets/click / cli

Function cli

examples/inout/inout.py:7–30  ·  view source on GitHub ↗

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 - \

(input, output)

Source from the content-addressed store, hash-verified

5@click.argument("input", type=click.File("rb"), nargs=-1)
6@click.argument("output", type=click.File("wb"))
7def cli(input, output):
8 """This script works similar to the Unix `cat` command but it writes
9 into a specific file (which could be the standard output as denoted by
10 the ``-`` sign).
11
12 \b
13 Copy stdin to stdout:
14 inout - -
15
16 \b
17 Copy foo.txt and bar.txt to stdout:
18 inout foo.txt bar.txt -
19
20 \b
21 Write stdin into the file foo.txt
22 inout - foo.txt
23 """
24 for f in input:
25 while True:
26 chunk = f.read(1024)
27 if not chunk:
28 break
29 output.write(chunk)
30 output.flush()

Callers

nothing calls this directly

Calls 3

readMethod · 0.80
writeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected