Class: TooDoo::Commands::Add

Inherits:
Base
  • Object
show all
Defined in:
lib/toodoo/commands/add.rb

Overview

add a new task usage: td add <body>

Instance Attribute Summary

Attributes inherited from Base

#args, #store

Instance Method Summary collapse

Methods inherited from Base

#initialize, #run!

Constructor Details

This class inherits a constructor from TooDoo::Commands::Base

Instance Method Details

#descriptionObject



10
11
12
13
14
15
# File 'lib/toodoo/commands/add.rb', line 10

def description
  <<~END
    add a new task
    usage: td add <task>
  END
end

#perform!Object



17
18
19
20
21
22
23
# File 'lib/toodoo/commands/add.rb', line 17

def perform!
  return puts(description) if args.empty?

  task = Task.new(args.join(' '))
  store.save(task)
  puts build_message(task)
end