Class: Tamarillo::Command
- Inherits:
-
Object
- Object
- Tamarillo::Command
- Defined in:
- lib/tamarillo/command.rb
Constant Summary collapse
- DEFAULT_PATH =
'~/.tamarillo'
- DEFAULT_COMMAND =
'status'
- HELP_TEXT =
<<-EOS Tamarillo v#{VERSION} Commands: $ tam status [--prompt] Displays remainder of current pomodoro, use the prompt switch to render a space-separated format for prompt integration. This is the default command. eg. 12:00 720 900 $ tam start Starts a new pomodoro if none in progress. $ tam stop $ tam interrupt Stops the current pomodoro if in progress. $ tam config $ tam config [duration=MINUTES] $ tam config [notifier=TYPE] Displays the current configuration, use to change then duration of each pomodoro in minutes or the type of notifier used. Notifiers: growl, speech, bell EOS
- VALID_COMMANDS =
%w[help status config start stop interrupt]
Instance Method Summary collapse
- #config(*args) ⇒ Object
- #execute(*args) ⇒ Object
- #help(*args) ⇒ Object
-
#initialize ⇒ Command
constructor
A new instance of Command.
- #interrupt(*args) ⇒ Object (also: #stop)
- #start(*args) ⇒ Object
- #status(*args) ⇒ Object
Constructor Details
Instance Method Details
#config(*args) ⇒ Object
78 79 80 81 82 |
# File 'lib/tamarillo/command.rb', line 78 def config(*args) params = Hash[args.map { |pair| pair.split('=', 2) }] @controller.update_config(params) puts @controller.config.to_yaml end |
#execute(*args) ⇒ Object
51 52 53 54 |
# File 'lib/tamarillo/command.rb', line 51 def execute(*args) command = parse_command_name!(args) send(command.to_sym, *args.drop(1)) end |
#help(*args) ⇒ Object
56 57 58 |
# File 'lib/tamarillo/command.rb', line 56 def help(*args) puts HELP_TEXT end |
#interrupt(*args) ⇒ Object Also known as: stop
73 74 75 |
# File 'lib/tamarillo/command.rb', line 73 def interrupt(*args) @controller.interrupt_current_tomato end |
#start(*args) ⇒ Object
68 69 70 71 |
# File 'lib/tamarillo/command.rb', line 68 def start(*args) tomato = @controller.start_new_tomato status unless tomato.nil? end |