Class: Toodledo::CommandLine::AddGoalCommand
- Inherits:
-
BaseCommand
- Object
- CmdParse::Command
- BaseCommand
- Toodledo::CommandLine::AddGoalCommand
- 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::DATE_REGEXP, ParserHelper::FOLDER_REGEXP, ParserHelper::GOAL_REGEXP, ParserHelper::LEVEL_REGEXP, ParserHelper::PRIORITY_REGEXP, ParserHelper::REGEXP_LIST, ParserHelper::STAR_REGEXP, ParserHelper::TAGS_REGEXP
Instance Method Summary collapse
- #execute(args) ⇒ Object
-
#initialize(client) ⇒ AddGoalCommand
constructor
A new instance of AddGoalCommand.
Methods included from ParserHelper
#parse_context, #parse_date, #parse_folder, #parse_goal, #parse_level, #parse_priority, #parse_remainder, #parse_star, #parse_tag, #strip_brackets
Methods inherited from BaseCommand
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. return -1 end |