-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulticlip.py
More file actions
36 lines (35 loc) · 913 Bytes
/
multiclip.py
File metadata and controls
36 lines (35 loc) · 913 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
28
29
30
31
32
33
34
35
36
import sys
import clipboard
import json
repo="clipboard.json"
def save_items(filepath, data):
with open(filepath,"w") as f:
json.dump(data,f)
def load_data(filepath):
try:
with open(filepath,"r") as f:
data=json.load(f)
return data
except:
return {}
if len(sys.argv)==2:
command=sys.argv[1]
data=load_data(repo)
if command=="save":
key=input("Enter a key: ")
data[key]=clipboard.paste()
save_items(repo,data)
print("Data Saved")
elif command=="load":
key=input("Enter a key: ")
if key not in data:
print("invalid key")
else:
clipboard.copy(data[key])
print("Data Loaded")
elif command=="list":
print(data)
else:
print("invalid command")
else:
print("pls pass exactly one command")