Sha256: 381f0055d387c209304bc6886004891eddcf1c7e4a55d69e6c1dcdec9b12c472
Contents?: true
Size: 929 Bytes
Versions: 2
Compression:
Stored size: 929 Bytes
Contents
#! /usr/bin/env ruby # coding: utf-8 # # USAGE: linesub [options] str0 str1 files ... require "pp" require "optparse" require "rubygems" require "tempfile" #gem "tefil" require "tefil.rb" ## option analysis options = {} op = OptionParser.new op.banner = [ "Usage: #{File.basename("#{__FILE__}")} [options] old_str new_str [files]", ].join("\n") op.on("-o" , "--overwrite" , "Overwrite"){ options[:overwrite] = true} op.on("-g" , "--global" , "Globally substitute"){ options[:global] = true} op.on("-r" , "--reg-exp" , "Regular expression for old_str"){ options[:regexp] = true} op.on("-f" , "--filename" , "Rename filename at the same time"){ options[:filename] = true} op.parse!(ARGV) old_str = ARGV.shift new_str = ARGV.shift options[:overwrite] ||= false #if options[:filename] # if FileTest.exist? new_str #end tf = Tefil::LineSubstituter.new(old_str, new_str, options) tf.filter(ARGV)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tefil-0.1.5 | bin/linesub |
tefil-0.1.4 | bin/linesub |