-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.') |