Class: Toycol::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/toycol/command.rb

Defined Under Namespace

Classes: Options

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Command

Returns a new instance of Command.



133
134
135
# File 'lib/toycol/command.rb', line 133

def initialize(argv)
  @argv = argv
end

Class Method Details

.run(argv) ⇒ Object



129
130
131
# File 'lib/toycol/command.rb', line 129

def self.run(argv)
  new(argv).execute
end

Instance Method Details

#executeObject



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/toycol/command.rb', line 137

def execute
  options = Options.parse!(@argv)
  command = options.delete(:command)

  case command
  when "client", "c"
    Client.execute!(options[:request_message])
  when "server", "s"
    ARGV.push("-q", "-s", "toycol")
    Rack::Server.start
  when "generate", "g"
    type = options[:template_type] || "all"
    TemplateGenerator.generate!(type: type, name: options[:protocol_name])
  end
end