Class: MicroManager::CLI::CommandBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/command_builder.rb

Instance Method Summary collapse

Instance Method Details

#build(input) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cli/command_builder.rb', line 8

def build(input)
  params = parse_input(input)

  if params[:help]
    ShowHelp.new(parser)
  elsif params[:"complete-task"]
    CompleteTask.new
  elsif params[:"list-tasks"] || params[:rest].empty?
    ListTasks.new
  else
    task = { description: params[:rest].join(" ") }
    task.merge!(due: params[:due]) if params[:due]
    AddTask.new(**task)
  end
end