lib/balboa/cli/defaults.rb in balboa-0.1.5 vs lib/balboa/cli/defaults.rb in balboa-0.1.6

- old
+ new

@@ -3,10 +3,12 @@ require 'yaml' module Balboa module CLI class Defaults + TOTAL_WORK_HOURS = 8 + def self.prompt(*args) new(*args).prompt end def initialize(cli, config = {}) @@ -34,10 +36,12 @@ file.write(@config.to_yaml) end end def prompt_attributes + @cli.say("\nFirst run. Please type your settings!") + @config['email'] = prompt_email @config['password'] = prompt_password @config['project'] = prompt_project end @@ -65,18 +69,26 @@ def prompt_start @cli.ask("\nFirst shift: ") { |qst| qst.default = '8' } end def prompt_lunch - @cli.ask("\nLunch: ") { |qst| qst.default = '12' } + default = @config['start_at'].to_i + 4 + + @cli.ask("\nLunch: ") { |qst| qst.default = default.to_s } end def prompt_restart - @cli.ask("\nSecond shift: ") { |qst| qst.default = '13' } + default = @config['lunch_at'].to_i + 1 + + @cli.ask("\nSecond shift: ") { |qst| qst.default = default.to_s } end def prompt_leave - @cli.ask("\nLeave: ") { |qst| qst.default = '17' } + default = TOTAL_WORK_HOURS + default -= @config['lunch_at'].to_i - @config['start_at'].to_i + default += @config['restart_at'].to_i + + @cli.ask("\nLeave: ") { |qst| qst.default = default.to_s } end end end end