#!/usr/bin/env ruby $: << File.expand_path(File.join(File.dirname(__FILE__), "../lib")) begin require 'rubikon' require 'ninjs' rescue LoadError require 'rubygems' require 'rubikon' require 'ninjs' end class NinjsConsole < Rubikon::Application::Base def initialize @directory = '/' end option :version option :v => :version default do if version.given? time = Time.now copyright_year = time.year == 2010 ? '2010' : '2010-' << time.year puts 'ninjs ' << Ninjs.version puts "Copyright (c) #{copyright_year} Dayton Nolan" puts "Released under the MIT License" else Ninjs::Command.help end end command :compile do Ninjs::Command.compile end command :watch do Ninjs::Command.watch end command :import do Ninjs::Command.import end option :withdir, :path flag :p => :withdir command :create, :app_name do directory = (given? :p) ? withdir.path : false Ninjs::Command.create(app_name, directory) end option :e option :m command :generate, :object, :obj_name do Ninjs::Command.generate('elements', obj_name) if e.given? Ninjs::Command.generate('model', obj_name) if m.given? elements = e.given? || false models = m.given? || false Ninjs::Command.generate(object, obj_name, elements, models) end end