else/Clipext/clipext.py
Ethan Dalool 82f63a75ab else
2016-08-17 18:24:38 -07:00

31 lines
728 B
Python

import pyperclip
CLIPBOARD_STRINGS = ['!c', '!clip', '!clipboard']
INPUT_STRINGS = ['!i', '!in', '!input', '!stdin']
EOF = '\x1a'
def multi_line_input():
userinput = []
while True:
try:
additional = input()
except EOFError:
# If you enter nothing but ctrl-z
additional = EOF
userinput.append(additional)
if EOF in additional:
break
userinput = '\n'.join(userinput)
userinput = userinput.split(EOF)[0]
return userinput.strip()
def resolve(arg):
lowered = arg.lower()
if lowered in CLIPBOARD_STRINGS:
return pyperclip.paste()
if lowered in INPUT_STRINGS:
return multi_line_input()
return arg