summaryrefslogtreecommitdiff
path: root/lib/un.rb
diff options
context:
space:
mode:
authorKazuhiro NISHIYAMA <[email protected]>2021-04-07 10:35:37 +0900
committerHiroshi SHIBATA <[email protected]>2021-08-24 18:02:44 +0900
commit2eed62fb65a93721bad32ecf79413b67320b61de (patch)
tree82b17c62a8c54bd24f06f9caa6bc191e32840af2 /lib/un.rb
parent66abeb0370feca203d1f179be39be158ba60aa6c (diff)
[ruby/un] Use STDIN if no arguments
https://github.com/ruby/un/commit/8e0d6f62cb
Diffstat (limited to 'lib/un.rb')
-rw-r--r--lib/un.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/un.rb b/lib/un.rb
index 75426ba17e..5feac92120 100644
--- a/lib/un.rb
+++ b/lib/un.rb
@@ -23,7 +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 colorize -- [FILE]
# ruby -run -e help [COMMAND]
require "fileutils"
@@ -377,7 +377,7 @@ end
##
# Colorize ruby code.
#
-# ruby -run -e colorize -- FILE
+# ruby -run -e colorize -- [FILE]
#
def colorize
@@ -387,6 +387,10 @@ def colorize
raise "colorize requires irb 1.1.0 or later"
end
setup do |argv, |
+ if argv.empty?
+ puts IRB::Color.colorize_code STDIN.read
+ return
+ end
argv.each do |file|
puts IRB::Color.colorize_code File.read(file)
end