-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
executable file
·27 lines (23 loc) · 725 Bytes
/
Copy pathcli.py
File metadata and controls
executable file
·27 lines (23 loc) · 725 Bytes
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
#!/usr/local/bin/python3
from sys import argv
import numerate
# Unix-like CLI:
# Main function
def main(argv):
# Attempt to parse arguments
if len(argv) < 1:
print("Please input at least one positive integer argument.")
elif len(argv) == 1:
try:
print(numerate.numerate(argv[0], "en"))
except KeyError:
print ("Error: Probably, the provided argument is not an integer.")
elif len(argv) == 2:
try:
print(numerate.numerate(argv[1], argv[0]))
except KeyError:
print ("Error: Probably, the provided argument is not an integer.")
else:
print("Too many arguments.")
if __name__ == "__main__":
main(argv[1:])