#!/usr/bin/env ruby

require 'fileutils'
require 'optparse'
require 'active_support/inflector'

gempath = Gem::Specification.find_by_name('JSONRecord').gem_dir
tables_dir = File.expand_path("#{gempath}/lib/tables",__FILE__)

if ARGV[0] == 'generate' and ARGV[1] == 'model'
  model_name = ARGV[2].to_s.pluralize
  FileUtils.touch "#{tables_dir}/#{model_name}.json"

  #Append an empty Array into the file.
  File.open("#{tables_dir}/#{model_name}.json", "w+") do |file|
    file.write("[]")
  end
  
  puts "JSONRecord table created : #{tables_dir}/#{model_name}.json"
end
