Class: PureMVCGen::Commands::NewCommand::CreateCommand

Inherits:
CmdParse::Command show all
Defined in:
lib/pure_m_v_c_gen/commands/new_command.rb

Instance Method Summary collapse

Methods inherited from CmdParse::Command

#default_options

Constructor Details

#initializeCreateCommand

Returns a new instance of CreateCommand.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/pure_m_v_c_gen/commands/new_command.rb', line 17

def initialize
  super('command', false)
  @type = :simple
  self.short_desc = "Creates a simple or macro command (defaults to simple)."
  self.description = <<-EOL
      Generates a simple or macro command.
      Generating a simple command is the default behavior, unless the macro switch is passed:
      -m or --macro

    If no other switches are passed, the ANT script will prompt for a command name and constant,
    however these may be passed on the command line with the -n (or --name) and -c (or --const) switches.
  EOL
  self.options = default_options do |opt|
    opt.on("-m", "--macro", "Specifies the command is a MacroCommand") { @type = :macro }
    opt.on("-n", "--name COMMAND_NAME", "Specifies the name for the command") { |name| @command_name = name }
    opt.on("-c", "--const COMMAND_CONSTANT", "Specifies the constant to use for the command") { |const| @command_const = const }
  end
end

Instance Method Details

#execute(args) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/pure_m_v_c_gen/commands/new_command.rb', line 36

def execute(args)
  cmd = ""
  cmd << "-Dcmd.name=#{@command_name} " unless @command_name.nil?
  cmd << "-Dcmd.const=#{@command_const} " unless @command_const.nil?
  cmd << "#{@type == :simple ? "create-simple-command" : "create-macro-command"}"
  call_ant cmd
end