Class: Pomodoro::Commands::Edit

Inherits:
Command
  • Object
show all
Defined in:
lib/pomodoro/commands/edit.rb

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Pomodoro::Commands::Command

Instance Method Details

#runObject


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pomodoro/commands/edit.rb', line 13

def run
  case @args.first
  when nil
    self.ensure_today; command("nvim #{self.config.today_path}")
  when '2'
    # This could also be tomorrow + tasks, not just today + tasks.
    self.ensure_today; self.ensure_task_list
    command("nvim -O2 #{self.config.today_path} #{self.config.task_list_path}")
  when '+1'
    tomorrow = Date.today + 1; self.ensure_today(tomorrow)
    command("nvim #{self.config.today_path(tomorrow)}")
  when 'tasks', 't'
    self.ensure_task_list; command("nvim #{self.config.task_list_path}")
  when 'config', 'c'
    command("nvim #{self.config.path}") # TODO: spec
  when 'schedules', 's' # TODO: spec
    command("atom #{File.dirname(self.config.schedule_path)}")
  else
    abort(self.class.help)
  end
end