Sha256: 67b3ec1e729cace2ecb5f992e9d6b536b44b275eab52766e215abdaf11961162

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

#! /usr/bin/env ruby
# coding: utf-8

require "pp"
require "optparse"
require "rubygems"
require "tefil"

# option analysis
OPTIONS = {}
op = OptionParser.new
op.banner = [
    "Usage: #{File.basename("#{__FILE__}")} old_width new_width [options] [files]",
    "Example: #{File.basename("#{__FILE__}")} 4 2 [options] [files]",
].join("\n")
op.on("-o"     , "--overwrite"     , "Overwrite."){    OPTIONS[:overwrite] = true}
#op.on("-m", "--minimum", "Show only minimum indent (not zero)."){ OPTIONS[:minimum] = true}
#op.on("-l"     , "--left-alline"   , "Left alline."){ OPTIONS[:left] = true}
op.parse!(ARGV)

#数値として識別できない文字列(to_i で 0 になる)はタブにする。
num = ARGV.shift.to_i
if num == 0
  old_char  = "\t"
  old_width = 1
else
  old_char  = ' '
  old_width = num
end

num = ARGV.shift.to_i
if num == 0
  new_char  = "\t"
  new_width = 1
else
  new_char  = ' '
  new_width = num
end

f = Tefil::IndentConverter.new(old_char, old_width, new_char, new_width, OPTIONS)
f.filter(ARGV)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tefil-0.1.0 bin/indentconv