-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtext-style
executable file
·53 lines (39 loc) · 1.18 KB
/
text-style
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
51
52
#!/usr/bin/env python
# coding: UTF-8
from unicode_text_style import *
#if __name__ == "__main__":
import sys
import argparse
PYPERCLIP = False
try:
import pyperclip
except ImportError:
pass
else:
PYPERCLIP = True
parser = argparse.ArgumentParser(
description='Style text using Unicode characters.')
addArg = parser.add_argument
addArg("text", type=lambda s: unicode(s, 'utf8'))
addArg("-a", "--all", action="store_true", dest="all",
help="Style all characters (including non-alphanumeric)")
addArg("-o", "--over", action="store_true", help="Overline")
addArg("-u", "--under", action="store_true", help="Underline")
addArg("-s", "--strike", action="store_true", help="Strikethrough")
if PYPERCLIP:
addArg("-c", "--clipboard", action="store_true", help="Copy to clipboard.")
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
if args.text:
char = ''
for k in CHARS:
if vars(args)[k]:
char += CHARS[k]
if not char:
char = CHARS['under']
text_styled = style_text(args.text, char, args.all)
print(text_styled)
if PYPERCLIP and args.clipboard:
pyperclip.copy(text_styled)