#!/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 :elements option :model flag :e => :elements flag :m => :model command :generate, :object, :obj_name do with = { :model => model.given?, :elements => elements.given? } Ninjs::Command.generate(object, obj_name, with) end command :upgrade do Ninjs::Command.upgrade end end