更好的红宝石终端着色库
有很多着色库:彩色,term-ansicolor。 但是有什么能做到这一点:更好的红宝石终端着色库
puts "#{'hello'.red} world!".bold 而且world!应该大胆。
为了明确这一点,我想这一点:
"\e[1m\e[31mhello\e[0m\e[1m world!\e[0m" 或更好即使是这样(只是短):
"\e[1;31mhello\e[0;1m world!\e[0m" ,而不是这样的:
"\e[1m\e[31mhello\e[0m world!\e[0m" 回答:
至于有没有,我写我自己,
二十一点和妓女
聪明的 - smart_colored
gem install smart_colored 和运行
require 'smart_colored/extend' # without extend you'll need to use 'string'.colored.red
puts "#{'hello'.red} world!".bold
回答:
的lib被称为Highline 它有一个color方法:say("This should be <%= color('bold', BOLD) %>!") 它可以很容易地用来实现String#bold。
回答:
如果你正在使用的Highline我做了一个宝石延长颜色并提供助手,如:
say_bold 'this is bold text' https://github.com/bonzofenix/highline-color
以上是 更好的红宝石终端着色库 的全部内容, 来源链接: utcz.com/qa/262338.html

