From c4be13505444f16be5647c56828a4e4f8c279343 Mon Sep 17 00:00:00 2001 From: Paul R Date: Tue, 19 Sep 2023 16:55:24 +0500 Subject: [PATCH] Create __main__.py --- pyperclip/__main__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 pyperclip/__main__.py diff --git a/pyperclip/__main__.py b/pyperclip/__main__.py new file mode 100644 index 0000000..39b9e98 --- /dev/null +++ b/pyperclip/__main__.py @@ -0,0 +1,18 @@ +import pyperclip +import sys + +if len(sys.argv) > 1 and sys.argv[1] in ('-c', '--copy'): + if len(sys.argv) > 2: + pyperclip.copy(sys.argv[2]) + else: + pyperclip.copy(sys.stdin.read()) +elif len(sys.argv) > 1 and sys.argv[1] in ('-p', '--paste'): + sys.stdout.write(pyperclip.paste()) +else: + print('Usage: python -m pyperclip [-c | --copy] [text_to_copy] | [-p | --paste]') + print() + print('If a text_to_copy argument is provided, it is copied to the') + print('clipboard. Otherwise, the stdin stream is copied to the') + print('clipboard. (If reading this in from the keyboard, press') + print('CTRL-Z on Windows or CTRL-D on Linux/macOS to stop.') + print('When pasting, the clipboard will be written to stdout.')