Class: Toodledo::CommandLine::AddTaskCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/toodledo/command_line/add_command.rb

Overview

Adds a task from the command line.

Instance Method Summary collapse

Methods inherited from BaseCommand

#client

Constructor Details

#initialize(client) ⇒ AddTaskCommand

Returns a new instance of AddTaskCommand.



109
110
111
112
113
# File 'lib/toodledo/command_line/add_command.rb', line 109

def initialize(client)
  super(client, 'add', false)
  self.short_desc = "Add a task"
  self.description = "Adds a task to Toodledo"
end

Instance Method Details

#execute(args) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/toodledo/command_line/add_command.rb', line 115

def execute(args)
  return if (args == nil)                
  Toodledo.begin(client.logger) do |session|            
    line = args.join(' ')
    client.add_task(session, line)
  end
    
  return 0
rescue ItemNotFoundError => e
  puts e.message
  return -1
end