Sha256: 28357db5f50ab9988b1fe633050fe9d6c94c16943e21ae0a36976ae827bafa55

Contents?: true

Size: 1.16 KB

Versions: 68

Compression:

Stored size: 1.16 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__} [--indent=string] input output",
    "  --indent=string, indent 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

68 entries across 68 versions & 1 rubygems

Version Path
bake-toolkit-2.46.0 bin/bake-format
bake-toolkit-2.45.0 bin/bake-format
bake-toolkit-2.44.1 bin/bake-format
bake-toolkit-2.44.0 bin/bake-format
bake-toolkit-2.43.2 bin/bake-format
bake-toolkit-2.43.1 bin/bake-format
bake-toolkit-2.43.0 bin/bake-format
bake-toolkit-2.42.3 bin/bake-format
bake-toolkit-2.42.2 bin/bake-format
bake-toolkit-2.42.1 bin/bake-format
bake-toolkit-2.42.0 bin/bake-format
bake-toolkit-2.41.4 bin/bake-format
bake-toolkit-2.41.3 bin/bake-format
bake-toolkit-2.41.2 bin/bake-format
bake-toolkit-2.41.1 bin/bake-format
bake-toolkit-2.41.0 bin/bake-format
bake-toolkit-2.40.1 bin/bake-format
bake-toolkit-2.40.0 bin/bake-format
bake-toolkit-2.39.1 bin/bake-format
bake-toolkit-2.39.0 bin/bake-format