Sha256: 10e1f68e78b1a904cfbad02cbc19be68059c5583afa7a8c0ce6fcd50e9474094

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

#!/bin/env ruby

if ARGV.empty?
  puts "Usage: #$0 <command> [args...]"
  puts "  Commands are: print_conf"
  exit 0
end

def load_config(command_name)
  require 'twiddler/config'
  require 'twiddler/parser'
  path = ARGV.shift
  if path.empty? or path.nil?
    puts "#{command_name} requires a config path"
    exit 1
  end
  return Twiddler::Parser.parse(File.read(path))
end

case command = ARGV.shift
when "print_conf"
  config = load_config("print_conf")
  p config
when "train_files"
  config = load_config("train_files")
  destdir = ARGV.shift
  require 'twiddler/rendering'

  dictionary = ARGV.shift || File::expand_path("../../dictionary.txt", __FILE__)

  if File::exists?(dictionary)
    require 'twiddler/target_builder'
    Twiddler::TargetBuilder::build(File::expand_path("challenges", destdir), dictionary, config)
  end

  Twiddler::Rendering.new(config).embed("lua")
  File::open(File::expand_path("chords.lua", destdir), "w") do |file|
    file.write(config.render)
  end
when "lint"
  config = load_config("lint")
  require 'twiddler/lint'
  report = Twiddler::Lint::check(config)
  puts report.join("\n")
else
  config = load_config(command)
  require 'twiddler/rendering'
  Twiddler::Rendering.new(config).embed(command)
  puts config.render
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twiddler-utils-0.0.3 bin/twid-utils