lib/jdt/commands/new.rb in jdt-0.0.2 vs lib/jdt/commands/new.rb in jdt-0.0.3

- old
+ new

@@ -1,31 +1,53 @@ require 'thor' +require 'thor/group' require 'nokogiri' module Jdt - class CLI < Thor - include Thor::Actions + class GeneratorCLI < Thor - desc "new TYPE NAME", "creates a stub of TYPE with NAME" - method_options :location => "." + desc "component NAME", "generate component with NAME" - def new(type, name) + def component(name) + ComponentGenerator.new.generate(name) + end - handle_errors do + desc "module NAME", "generate module with NAME" - begin - generator = Generator.find(type.to_sym, name) - generator.location = options[:location] - generator.generate - rescue Jdt::ExtensionTypeNotFoundError - say("Given type is no Joomla extension type. Chose one of the available Joomla extension types:") - say("Extension types: #{Generator::GENERATORS.join(" ")}") - end + def module(name) + ModuleGenerator.new.generate(name) + end - end - + desc "plugin NAME", "generate plugin with NAME" + + def plugin(name) + PluginGenerator.new.generate(name) end + desc "language NAME", "generate language with NAME" + + def language(name) + LanguageGenerator.new.generate(name) + end + + desc "template NAME", "generate template with NAME" + + def template(name) + TemplateGenerator.new.generate(name) + end + + desc "library NAME", "generate library with NAME" + + def library(name) + LibraryGenerator.new.generate(name) + end + end + + class CLI < Thor + register Jdt::GeneratorCLI, :new, "new <command>", "Commands for new extensions" + end + + end \ No newline at end of file