-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuncmd.py
More file actions
31 lines (29 loc) · 1.07 KB
/
funcmd.py
File metadata and controls
31 lines (29 loc) · 1.07 KB
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
import argparse as ap
import sys
parser = ap.ArgumentParser()
parser.add_argument("-a", "--add-item", help = "add a new command to the list", action="store_true")
parser.add_argument("-c", "--clear", help = "add a new command to the list", action="store_true")
args = parser.parse_args()
def main():
try:
if args.add_item:
new_command = input("What do you want to add?:")
commands = open("/usr/lib/funlist.txt", "a")
commands.write("- " + new_command + "\n")
commands.close()
elif args.clear:
try:
commands = open("/usr/lib/funlist.txt", "w")
commands.write("")
commands.close()
except:
print("an error occured, try running this command as sudo")
else:
commands = open("/usr/lib/funlist.txt", "r")
print("Fun Commands List\n\n" + commands.read())
commands.close()
except:
temp_list = open("/usr/lib/funlist.txt", "w")
temp_list.close()
if __name__ == "__main__":
main()