ruby-changes:67237
From: Kazuhiro <ko1@a...>
Date: Tue, 24 Aug 2021 18:02:58 +0900 (JST)
Subject: [ruby-changes:67237] 66abeb0370 (master): [ruby/un] Add colorize command
https://git.ruby-lang.org/ruby.git/commit/?id=66abeb0370 From 66abeb0370feca203d1f179be39be158ba60aa6c Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA <zn@m...> Date: Tue, 6 Apr 2021 18:37:09 +0900 Subject: [ruby/un] Add colorize command https://github.com/ruby/un/commit/4d080eeec0 --- lib/un.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/un.rb b/lib/un.rb index 208e16c..75426ba 100644 --- a/lib/un.rb +++ b/lib/un.rb @@ -23,6 +23,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/un.rb#L23 # 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 https://github.com/ruby/ruby/blob/trunk/lib/un.rb#L375 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] -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/