#!/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 flag :v => :version option :version default do if version.given? time = Time.now Ninjs::Notification.notice 'ninjs ' + Ninjs::VERSION Ninjs::Notification.notice "Copyright (c) #{time.year} Dayton Nolan" Ninjs::Notification.notice "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 command :create, :app_name, :dir => :optional do dir.nil? ? Ninjs::Command.create(app_name) : Ninjs::Command.create(app_name, dir) end option :e option :m command :generate, :object, :obj_name do with = { :model => m.given?, :elements => e.given? } Ninjs::Command.generate(object, obj_name, with) end command :upgrade do Ninjs::Command.upgrade end end