bin/ninjs in ninjs-0.13.4 vs bin/ninjs in ninjs-0.13.5

- old
+ new

@@ -10,20 +10,11 @@ require 'ninjs' require 'optparse' end header = <<-HEADER -ninjs #{Ninjs::VERSION} -Copyright (c) #{Time.new.year} Dayton Nolan -Released under the MIT License -Description: -The ninjs command line application is a simple way to quickly develop and manage your application. With it you can create an application, generate scaffolding, compile, and upgrade your application. - -Usage: ninjs [command] [arguments] [options (-h, --help)] - -Commands: HEADER create = <<-CREATE create Creates a new ninjs application in the current working directory or sub directory within. @@ -109,20 +100,24 @@ options[:help] = true end opts.on( '-v', '--version', 'Display the version') do 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" + puts Ninjs::Notification.notice 'ninjs ' + Ninjs::VERSION + puts Ninjs::Notification.notice "Copyright (c) #{time.year} Dayton Nolan" + puts Ninjs::Notification.notice "Released under the MIT License" exit end - opts.on( '-a', '--alias', 'Generate application alias') do - options[:alias] = true + opts.on( '-a', '--alias [alias]', 'Generate application alias') do |als| + options[:alias] = als || "app" end + opts.on( '-d', '--dest [dest]', 'Module destination directory') do |dest| + options[:dest] = dest + end + opts.on('-e', '--elements', 'Generate elements file') do options[:elements] = true end opts.on('-m', '--model', 'Generate model file') do @@ -156,14 +151,16 @@ when "generate" if options[:help] puts help[:generate] exit end + errors = Hash.new type = ARGV[1] name = ARGV[2] - als = ARGV[3] || 'app' + als = options[:alias] || nil + dest = options[:dest] || nil errors[:type] = "Error! Scaffold type is required (ninjs generate module mymodule)" if type.nil? errors[:name] = "Error! Module name is required (ninjs generate module mymodule)" if name.nil? unless errors.empty? @@ -171,19 +168,23 @@ puts error end exit end - with = { + dependencies = { :model => options[:model], :elements => options[:elements] } - if options[:alias] - Ninjs::Command.generate_with_alias(type, name, with, als) - else - Ninjs::Command.generate(type, name, with) - end + config = { + :type => type, + :name => name, + :alias => als, + :dest => dest, + :dependencies => dependencies + } + + Ninjs::Command.generate(config) # compile when "compile" if options[:help] puts help[:compile] exit \ No newline at end of file