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 =
"Tamarillo v\#{VERSION}\n\nCommands:\n\n$ tam status [--prompt]\n\nDisplays remainder of current pomodoro, use the prompt switch\nto render a space-separated format for prompt integration. This\nis the default command.\n\neg. 12:00 720 900\n\n\n$ tam start\n\nStarts a new pomodoro if none in progress.\n\n\n$ tam stop\n$ tam interrupt\n\nStops the current pomodoro if in progress.\n\n\n$ tam config\n$ tam config [duration=MINUTES]\n$ tam config [notifier=TYPE]\n\nDisplays the current configuration, use to change then duration of \neach pomodoro in minutes or the type of notifier used. \n\nNotifiers: growl, speech, bell\n"- 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
#initialize ⇒ Command
Returns a new instance of Command.
45 46 47 48 49 |
# File 'lib/tamarillo/command.rb', line 45 def initialize config = Tamarillo::Config.load(config_path) storage = Storage.new(tamarillo_path, config) @controller = Controller.new(config, storage) end |
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 |
#status(*args) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/tamarillo/command.rb', line 60 def status(*args) format = Formats::HUMAN format = Formats::PROMPT if args.include?('--prompt') status = @controller.status(format) puts status unless status.nil? end |