bin/genit in genit-1.0.1 vs bin/genit in genit-2.0

- old
+ new

@@ -30,51 +30,49 @@ include Genit module Genit class AbstractCommand < Clamp::Command - option ['-v', '--version'], :flag, "print version" do puts "genit #{File.read(File.join($GENIT_PATH, 'VERSION')).strip}" exit 0 end - end - + + # Command to create a project. class CreateCommand < AbstractCommand - parameter "NAME", "the name of the project", :attribute_name => :project_name - option ["-d", "--doctype"], "DOCTYPE", "The Document Type Definition", :default => "html_5" - option ["-e", "--empty"], :flag, "Do not produce smoke test", :default => false + parameter "NAME", "the name of the project", + :attribute_name => :project_name + option ["-e", "--empty"], :flag, "Do not produce smoke test", + :default => false - def execute - valid_doctypes = ['xhtml_1.0_strict', 'xhtml_1.0_transitional', 'html_5'] - unless valid_doctypes.include? doctype - puts 'Valid doctypes are ' + valid_doctypes.inspect - exit 1 - end - project = ProjectCreator.new project_name, doctype, empty? + project = ProjectCreator.new project_name, empty? project.create end - end - - class CompileCommand < AbstractCommand + # Command to compile a project. + class CompileCommand < AbstractCommand def execute compiler = Compiler.new Dir.getwd compiler.compile end - end - + + # Command to start the web server. + class ServerCommand < AbstractCommand + def execute + Server.new(Dir.getwd).start + end + end + class MainCommand < AbstractCommand - subcommand "create", "Create a project.", CreateCommand subcommand "compile", "Compile the web site.", CompileCommand subcommand "cc", "Compile the web site.", CompileCommand - + subcommand "server", "Run WEBrick.", ServerCommand end end Genit::MainCommand.run