From 33bab6c024bc29243493f73893b39184d8b5cb58 Mon Sep 17 00:00:00 2001 From: Greg Jastrab Date: Fri, 5 Dec 2008 11:10:22 -0500 Subject: [PATCH] Added initial command line parsing to puremvc-gen binary Using CmdParse to handle command line arguments. Fixed a few templates --- bin/puremvc-gen | 46 ++++++++++++++++++++++++++-- conf/build.xml | 8 +++-- conf/templates/standard/Mediator.tpl | 1 + conf/templates/standard/Proxy.tpl | 2 +- 4 files changed, 50 insertions(+), 7 deletions(-) diff --git a/bin/puremvc-gen b/bin/puremvc-gen index 71d5fab..e2b613e 100644 --- a/bin/puremvc-gen +++ b/bin/puremvc-gen @@ -1,6 +1,46 @@ #!/usr/bin/env ruby +require 'rubygems' +require 'cmdparse' -puts "About to run the ant script" +BUILDFILE = File.join(File.dirname(__FILE__), '..', 'conf', 'build.xml') -path = File.join(File.dirname(__FILE__), '..', 'conf', 'build.xml') -system "ant -f #{path}" +def call_ant(args='') + system "ant -f #{BUILDFILE} -Dbasedir=#{Dir.pwd} #{args}" +end + +class CheckCommand < CmdParse::Command + + def initialize + super('check', false) + self.short_desc = "Validates that all required property settings are current detected" + end + + def execute(args) + call_ant "validate-properties" + end +end + +class InitializeCommand < CmdParse::Command + + def initialize + super('init', false) + self.short_desc = "Initializes the current working directory with a new PureMVC project" + end + + def execute(args) + call_ant "new-pmvc" + end + +end + +cmd = CmdParse::CommandParser.new(true, true) +cmd.program_name = "puremvc-gen" +cmd.version = [0, 0, 1] + +cmd.add_command(CmdParse::HelpCommand.new) +cmd.add_command(CmdParse::VersionCommand.new) + +cmd.add_command(CheckCommand.new) +cmd.add_command(InitializeCommand.new) + +cmd.parse diff --git a/conf/build.xml b/conf/build.xml index 061bbb3..5feff05 100644 --- a/conf/build.xml +++ b/conf/build.xml @@ -182,7 +182,7 @@ Creating PureMVC directories in ${core.dir} - + @@ -248,6 +248,7 @@ + @@ -293,9 +294,10 @@ ${log.gen.startup.command} + - + diff --git a/conf/templates/standard/Mediator.tpl b/conf/templates/standard/Mediator.tpl index 5e98c2f..5628c2f 100644 --- a/conf/templates/standard/Mediator.tpl +++ b/conf/templates/standard/Mediator.tpl @@ -2,6 +2,7 @@ package @namespace@.@view@ { import @namespace@.@facade@; + import org.puremvc.as3.interfaces.INotification; import org.puremvc.as3.patterns.mediator.Mediator; /** diff --git a/conf/templates/standard/Proxy.tpl b/conf/templates/standard/Proxy.tpl index e77de8a..39f0c2f 100644 --- a/conf/templates/standard/Proxy.tpl +++ b/conf/templates/standard/Proxy.tpl @@ -41,7 +41,7 @@ package @namespace@.@model@ { /* --- Public Accessors --- */ - public function get data():Object { return data; } + public function get dataObject():Object { return data; } /* === Public Accessors === */