diff options
author | Kazuhiro NISHIYAMA <[email protected]> | 2021-04-06 18:37:09 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2021-08-24 18:02:44 +0900 |
commit | 66abeb0370feca203d1f179be39be158ba60aa6c (patch) | |
tree | b85e96b2a807dbc826334ee42956b8f35d419fc1 | |
parent | d140b03053dad873483b763ebb51c775bff1edb7 (diff) |
[ruby/un] Add colorize command
https://github.com/ruby/un/commit/4d080eeec0
-rw-r--r-- | lib/un.rb | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -23,6 +23,7 @@ # ruby -run -e wait_writable -- [OPTION] FILE # ruby -run -e mkmf -- [OPTION] EXTNAME [OPTION] # ruby -run -e httpd -- [OPTION] [DocumentRoot] +# ruby -run -e colorize -- FILE # ruby -run -e help [COMMAND] require "fileutils" @@ -374,6 +375,25 @@ def httpd end ## +# Colorize ruby code. +# +# ruby -run -e colorize -- FILE +# + +def colorize + begin + require "irb/color" + rescue LoadError + raise "colorize requires irb 1.1.0 or later" + end + setup do |argv, | + argv.each do |file| + puts IRB::Color.colorize_code File.read(file) + end + end +end + +## # Display help message. # # ruby -run -e help [COMMAND] |