Class: Toodledo::CommandLine::AddContextCommand

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

Overview

Adds a context from the command line

Instance Method Summary collapse

Methods inherited from BaseCommand

#client

Constructor Details

#initialize(client) ⇒ AddContextCommand

Returns a new instance of AddContextCommand.



84
85
86
87
88
# File 'lib/toodledo/command_line/add_command.rb', line 84

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

Instance Method Details

#execute(args) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/toodledo/command_line/add_command.rb', line 90

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