-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpattern_with_cli.py
56 lines (43 loc) · 1.04 KB
/
pattern_with_cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import click
def func(N, value, sep=None):
mul = 2
if sep:
value = f"{sep}{value}{sep}"
mul = 6
print(
*[(value * n).center(mul * N, " ") for n in range(1, 2 * N - 1, 2)],
*[(value * n).center(mul * N, " ") for n in range(2 * N - 1, 0, -2)],
sep="\n",
file=open("console.txt", "a"),
)
@click.command()
@click.option("--count", type=click.IntRange(1, 50, clamp=True))
@click.option("--value", default="*")
def repeat(count, value):
func(count, value)
if __name__ == "__main__":
repeat()
"""
USAGE
>python3 <file>.py --count=10 --value=$
OUTPUT CONSOLE WRITTEN INTO FILE
$
$$$
$$$$$
$$$$$$$
$$$$$$$$$
$$$$$$$$$$$
$$$$$$$$$$$$$
$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$
$$$$$$$$$$$$$
$$$$$$$$$$$
$$$$$$$$$
$$$$$$$
$$$$$
$$$
$
"""