Sha256: 38a4d800bcf68452edebe98f59ff066a89f048d9d9b3ad8bdff75642fdc783e5
Contents?: true
Size: 752 Bytes
Versions: 814
Compression:
Stored size: 752 Bytes
Contents
#!/usr/bin/env ruby require 'rbbt-util' require 'rbbt/util/simpleopt' $0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands options = SOPT.setup <<EOF Matches text and colors it. $ rbbt color <file|-> (<color> <pattern>)+ Use - to read from STDIN. Example: `rbbt color - red "/.*rbbt.*/"` -h--help Print help EOF rbbt_usage and exit 0 if options[:help] file, *rest = ARGV if file == '-' text = STDIN.read else text = Open.read(file) end while rest.any? color = rest.shift pattern = rest.shift color = color.to_sym if pattern =~ /^\/(.*)\/$/ text.gsub!(Regexp.compile($1)){|match| Log.color color, match } else text.gsub!(pattern){|match| Log.color color, match } end end puts text
Version data entries
814 entries across 814 versions & 1 rubygems