Skip to content

Commit 0f55395

Browse files
committed
yes: Add yes.py
1 parent ac50c79 commit 0f55395

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/yes.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/python3
2+
3+
import sys
4+
from optparse import OptionParser
5+
6+
7+
def yes(_, strings: list[str]):
8+
try:
9+
string = " ".join(strings or ["y"])
10+
while True:
11+
print(string)
12+
except KeyboardInterrupt:
13+
sys.exit(130)
14+
15+
16+
if __name__ == "__main__":
17+
parser = OptionParser(
18+
usage="Usage: %prog [STRING]...",
19+
description="Repeatedly output a line with STRING(s) (or 'y' by default).",
20+
add_help_option=False,
21+
)
22+
parser.add_option("--help", action="help", help="show usage information and exit")
23+
24+
yes(*parser.parse_args())

0 commit comments

Comments
 (0)