Sha256: 684f8f46625b846b730c1e0356c40c6afd853ddb50cbd82c5785b43c7fbb9ca3

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

#!/usr/bin/env ruby

$:.unshift(File.dirname(__FILE__)+"/../lib")

require 'format/bake_format'
begin
  if ARGV.size == 2
    indent = '  '
    input = ARGV[0]
    output = ARGV[1]
  elsif ARGV.size == 3
    indent = ARGV[0]
    indent = indent.split('=')
    raise 'indent must have =' unless indent.size == 2
    raise 'indent must start with --indent' unless indent.first == '--indent'
    indent = indent.last
    input = ARGV[1]
    output = ARGV[2]
  else
    raise 'cannot understand'
  end
rescue
  puts [
    "Usage: #{__FILE__} [--ident=string] input output",
    "  --indent=string, ident defaults to two spaces.",
    "    Note, you can escape a tab in bash by ctrl-vTAB with sourrounding \" e.g. \"--input=    \"",
    "  input, filename or '-' for stdin",
    "  output, filename, '-' for stdout, '--' for same as input file"
  ].join("\n")
  exit 1
end

data =
  if input == '-'
    STDIN.read
  else
    File.read(input)
  end

out =
  if output == '-'
    STDOUT
  elsif output == '--'
    out = input == STDIN ? STDOUT : File.open(input, 'w')
  else
    File.open(output, 'w')
  end

bake_format(data, out, indent)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bake-toolkit-2.24.6 bin/bake-format
bake-toolkit-2.24.5 bin/bake-format
bake-toolkit-2.24.4 bin/bake-format
bake-toolkit-2.24.3 bin/bake-format