Skip to content

Commit 205a582

Browse files
committed
logname: Add logname.py
1 parent 08d8b7c commit 205a582

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/logname.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 os
4+
from optparse import OptionParser
5+
6+
7+
def logname():
8+
print(os.getlogin())
9+
10+
11+
if __name__ == "__main__":
12+
parser = OptionParser(
13+
usage="Usage: %prog",
14+
description="Print the current user's login name.",
15+
add_help_option=False,
16+
)
17+
parser.add_option("--help", action="help", help="show usage information and exit")
18+
19+
opts, args = parser.parse_args()
20+
21+
if args:
22+
parser.error(f"extra operand '{args[0]}'")
23+
24+
logname()

0 commit comments

Comments
 (0)