Skip to content

Commit

Permalink
Add colorize command
Browse files Browse the repository at this point in the history
  • Loading branch information
znz committed Apr 6, 2021
1 parent 762c38c commit 4d080ee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ruby -run -e touch -- [OPTION] FILE
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]
```

Expand Down
20 changes: 20 additions & 0 deletions lib/un.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -354,6 +355,25 @@ def httpd
end
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.
#
Expand Down

0 comments on commit 4d080ee

Please sign in to comment.