#!python3
#运行 py mcb.pyw save spam ,剪贴板内容就关键字spam保存
#py mcb.pyw spam 加载spam 对应内容到剪贴板
#py mcb.pyw list 关键字列表到剪贴板
#扩展多重剪贴板:
#增加delete <keyword>,从shelf中删除相应键值
#delete all 清空
import sys,pyperclip,shelve
mcbShelf=shelve.open(r'I:\mcb')
#save clipboasr content:
if len(sys.argv) == 3:
if sys.argv[1].lower()=='save' and sys.argv[2].lower() != 'all':
mcbShelf[sys.argv[2]] = pyperclip.paste()
elif sys.argv[1].lower()=='delete' and sys.argv[2].lower()=='all':
mcbShelf.clear()
elif sys.argv[1].lower()=='delete' and sys.argv[2] in mcbShelf:
del mcbShelf[sys.argv[2]]
elif len(sys.argv) == 2:
#List keywords and load content.
if sys.argv[1]=='list':
pyperclip.copy(str(list(mcbShelf.keys())))
elif sys.argv[1] in mcbShelf:
pyperclip.copy(mcbShelf[sys.argv[1]])
else:
print("参数错误")
else:
print('wrong')
mcbShelf.close()