命令行工具美化程序。
ecstas的Python项目详细描述
狂喜在这里,使您的命令行工具美丽和花哨。
命令行工具的输出没有摇头丸:
命令行工具的输出带有(on?)狂喜:
用法
要使用摇头丸,您可以使用摇头丸的特殊语法标记一个标准的python字符串,选择一些时髦的样式和格式标志,将它们传递给package-level beautiffy()方法,作为回报,获得您美化的字符串,准备好在打印到命令行时踢屁股:
importecstasy# <...> is a normal phrase, its style is determined by its position# <(x)...> is a phrase with an argument, its style is the one at index 'x'# <<...> <...>> is a phrase with nested phrases, their styles cascadetext="<Cats> are <(0)just> <<small>, furry <elephants>>!"# Beautify text by specifying styles via flag combinationstext=ecstasy.beautify(text,ecstasy.Style.Blink|ecstasy.Color.Red,ecstasy.Style.Bold|ecstasy.Fill.Blue,ecstasy.Color.Magenta|ecstasy.Style.Underline,small=ecstasy.Style.Invert|ecstasy.Color.White)# Keyword arguments (small=...) cause all phrases matching the string of# the key to have the style specified by the keyword argument's value.print(text)
在命令行输出的脚本中运行此命令:
安装
现在您确信,可以使用pip安装摇头丸:
$ pip install ecstasy
…然后开始干。
Documentation
完整的文档和用法说明,指定了所有可能的选项以及如何使用摇头丸美化字符串的可能性,可以在here中找到。
兼容性
python版本
使用Python3.4和Python2.7构建。此外,还成功地移植到Python2.6、3.2和3.3并用它进行了测试。看看Travis有什么要说的。
终端支持
与你的mac终端一起工作。有关更多信息,请享用这张桌子:
Terminal | Bold | Dim | Underlined | Blink | Invert | Hidden | Color |
---|---|---|---|---|---|---|---|
aTerm | ✓ | X | ✓ | X | ✓ | X | ✓ |
Eterm | (1) | X | ✓ | X | ✓ | X | ✓ |
GNOME | ✓ | ✓ | ✓ | X | ✓ | ✓ | ✓ |
Guake | ✓ | ✓ | ✓ | X | ✓ | ✓ | ✓ |
Konsole | ✓ | X | ✓ | ✓ | ✓ | X | ✓ |
Nautilus | ✓ | ✓ | ✓ | X | ✓ | ✓ | ✓ |
rxvt | ✓ | X | ✓ | (2) | ✓ | X | ✓ |
Terminator | ✓ | ✓ | ✓ | X | ✓ | ✓ | ✓ |
Tilda | ✓ | X | ✓ | X | ✓ | X | ✓ |
XFCE4 | ✓ | ✓ | ✓ | X | ✓ | ✓ | ✓ |
XTerm | ✓ | X | ✓ | ✓ | ✓ | ✓ | ✓ |
xvt | ✓ | X | ✓ | X | ✓ | X | X |
Linux TTY | ✓ | X | X | X | ✓ | X | ✓ |
VTE | ✓ | ✓ | ✓ | X | ✓ | ✓ | ✓ |
(1)用浅色代替粗体。
(2)用浅色代替闪烁。
License
摇头丸在MIT license下释放。