Class: Toodledo::CommandLine::AddGoalCommand

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

Overview

Adds a goal from the command line

Constant Summary

Constants included from ParserHelper

ParserHelper::CONTEXT_REGEXP, ParserHelper::FOLDER_REGEXP, ParserHelper::GOAL_REGEXP, ParserHelper::LEVEL_REGEXP, ParserHelper::PRIORITY_REGEXP, ParserHelper::REGEXP_LIST

Instance Method Summary collapse

Methods included from ParserHelper

#parse_context, #parse_folder, #parse_goal, #parse_level, #parse_priority, #parse_remainder, #strip_brackets

Methods inherited from BaseCommand

#client

Constructor Details

#initialize(client) ⇒ AddGoalCommand

Returns a new instance of AddGoalCommand.



59
60
61
62
63
# File 'lib/toodledo/command_line/add_command.rb', line 59

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

Instance Method Details

#execute(args) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/toodledo/command_line/add_command.rb', line 65

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