Skip to content

Commit dd275b5

Browse files
committed
ch02: create initial program
1 parent 6616852 commit dd275b5

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ tex2pdf*
1111
.coverage
1212
.idea
1313
.vscode
14-
02_crowsnest/crowsnest.py
1514
03_picnic/picnic.py
1615
04_jump_the_five/jump.py
1716
05_howler/howler.py

02_crowsnest/crowsnest.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python
2+
"""
3+
Author : Jeffrey Schmid-Paz
4+
Date : 2023-01-02
5+
Purpose: Warn captain for a something near the ship
6+
"""
7+
8+
import argparse
9+
10+
11+
# --------------------------------------------------
12+
def get_args():
13+
"""Get command-line arguments"""
14+
15+
parser = argparse.ArgumentParser(
16+
description="Crow's Nest -- choose the correct article",
17+
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
18+
)
19+
20+
parser.add_argument("word", metavar="word", help="A word")
21+
22+
return parser.parse_args()
23+
24+
25+
# --------------------------------------------------
26+
def main():
27+
"""Run the program"""
28+
29+
args = get_args()
30+
pos_arg = args.positional
31+
32+
print(f'positional = "{pos_arg}"')
33+
34+
35+
# --------------------------------------------------
36+
if __name__ == "__main__":
37+
main()

0 commit comments

Comments
 (0)