-
Notifications
You must be signed in to change notification settings - Fork 44
/
cb.py
executable file
·50 lines (38 loc) · 1.14 KB
/
cb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
"""
print the content of the clipboard to the standard output
Last update: 2017-01-08 (yyyy-mm-dd)
"""
import sys
import config as cfg
from lib import clipboard as cb
from lib import fs
from pathlib import Path
fs.check_if_available(cfg.XSEL, "Error: {} is not available!".format(cfg.XSEL))
def print_help():
print("""
Usage: {0} [options]
Options:
-h, --help this help
-1 read from primary clipboard (default)
-2 read from secondary clipboard
""".strip().format(Path(sys.argv[0]).name))
def process_parameters(params):
for e in params:
if e == "-1":
print(cb.read_primary())
elif e == "-2":
print(cb.read_clipboard())
else:
print("Error: {0} is an unknown option.".format(e))
exit(1)
#############################################################################
if __name__ == "__main__":
if len(sys.argv) == 1:
sys.argv.append("-1") # default
# else
if '-h' in sys.argv or '--help' in sys.argv:
print_help()
exit(0)
# else
process_parameters(sys.argv[1:])