Sha256: e481c625307b05e0aeab3429ad074687161d1eceb33012dea091ec7dc7f5e953

Contents?: true

Size: 847 Bytes

Versions: 26

Compression:

Stored size: 847 Bytes

Contents

#!/usr/bin/env ruby

unless ARGV[0]
  $stderr.puts "Please provide a list of indender strings"
  $stderr.puts "(separated by a colon character) as argv 1"
  exit 1
end

unless ARGV[1]
  $stderr.puts "Please provide a list of outdenter strings"
  $stderr.puts "(separated by a colon character) as argv 2"
  exit 1
end

unless ARGV[2]
  $stderr.puts "Please provide a string to indent with"
  $stderr.puts "as argv 3"
  exit 1
end

indenters  = ARGV[0].split(':')
outdenters = ARGV[1].split(':')

INDENT_REGEX  = /#{indenters * '|'}/
OUTDENT_REGEX = /#{outdenters * '|'}/
INDENT_STR    = "#{ARGV[2]}"

multiplier = 0

STDIN.each_line do |line|
  if line =~ OUTDENT_REGEX
    multiplier -= 1
    if multiplier < 0
      multiplier = 0
    end
  end
  puts "#{INDENT_STR * multiplier} #{line}"
  if line =~ INDENT_REGEX
    multiplier += 1
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
ix-cli-0.0.27 bin/ix-indent
ix-cli-0.0.26 bin/ix-indent
ix-cli-0.0.25 bin/ix-indent
ix-cli-0.0.24 bin/ix-indent
ix-cli-0.0.23 bin/ix-indent
ix-cli-0.0.22 bin/ix-indent
ix-cli-0.0.21 bin/ix-indent
ix-cli-0.0.20 bin/ix-indent
ix-cli-0.0.19 bin/ix-indent
ix-cli-0.0.18 bin/ix-indent
ix-cli-0.0.17 bin/ix-indent
ix-cli-0.0.16 bin/ix-indent
ix-cli-0.0.15 bin/ix-indent
ix-cli-0.0.14 bin/ix-indent
ix-cli-0.0.13 bin/ix-indent
ix-cli-0.0.12 bin/ix-indent
ix-cli-0.0.11 bin/ix-indent
ix-cli-0.0.10 bin/ix-indent
ix-cli-0.0.9 bin/ix-indent
ix-cli-0.0.7 bin/ix-indent