lib/imap/backup/configuration/setup.rb in imap-backup-1.0.14 vs lib/imap/backup/configuration/setup.rb in imap-backup-1.0.15

- old
+ new

@@ -10,11 +10,11 @@ attr_accessor :highline end self.highline = HighLine.new def run - setup_logging + Imap::Backup.setup_logging config catch :done do loop do system('clear') show_menu end @@ -26,21 +26,27 @@ def show_menu self.class.highline.choose do |menu| menu.header = 'Choose an action' account_items menu add_account_item menu + toggle_logging_item menu menu.choice('save and exit') do config.save throw :done end - menu.choice(:quit) { throw :done } + menu.choice('exit without saving changes') do + throw :done + end end end def account_items(menu) config.accounts.each do |account| - menu.choice("#{account[:username]}") do + next if account[:delete] + item = account[:username].clone + item << ' *' if account[:modified] + menu.choice(item) do edit_account account[:username] end end end @@ -49,20 +55,20 @@ username = Configuration::Asker.email edit_account username end end - def config - @config ||= Configuration::Store.new + def toggle_logging_item(menu) + menu_item = config.debug? ? 'stop logging' : 'start logging' + new_setting = ! config.debug? + menu.choice(menu_item) do + config.debug = new_setting + Imap::Backup.setup_logging config + end end - def setup_logging - Imap::Backup.logger.level = - if config.debug? - ::Logger::Severity::DEBUG - else - ::Logger::Severity::ERROR - end + def config + @config ||= Configuration::Store.new end def default_account_config(username) account = { :username => username,