Skip to content

Commit

Permalink
Create __main__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Pau1R authored Sep 19, 2023
1 parent 0069f37 commit c4be135
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pyperclip/__main__.py
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.')

0 comments on commit c4be135

Please sign in to comment.