Sha256: cbbcf7b5e78aeab148f0d9ea5d9420df2e1000eafb260ab2964b990a1c6eb1dc

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

require "imap/backup/configuration"
require "imap/backup/setup/global_options/download_strategy_chooser"

module Imap; end

module Imap::Backup
  class Setup; end

  class Setup::GlobalOptions
    attr_reader :config
    attr_reader :highline

    def initialize(config:, highline:)
      @config = config
      @highline = highline
    end

    def run
      catch :done do
        loop do
          Kernel.system("clear")
          show_menu
        end
      end
    end

    private

    def show_menu
      highline.choose do |menu|
        menu.header = <<~MENU.chomp
          Global Options

          These settings affect all accounts.

          Choose an action
        MENU
        change_download_strategy menu
        menu.choice("(q) return to main menu") { throw :done }
        menu.hidden("quit") { throw :done }
      end
    end

    def change_download_strategy(menu)
      strategies = Imap::Backup::Configuration::DOWNLOAD_STRATEGIES
      current = strategies.find { |s| s[:key] == config.download_strategy }
      changed = config.download_strategy_modified ? " *" : ""
      menu.choice("change download strategy (currently: '#{current[:description]}')#{changed}") do
        DownloadStrategyChooser.new(config: config, highline: Setup.highline).run
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
imap-backup-11.1.0 lib/imap/backup/setup/global_options.rb
imap-backup-11.1.0.rc1 lib/imap/backup/setup/global_options.rb
imap-backup-11.0.1 lib/imap/backup/setup/global_options.rb
imap-backup-11.0.0 lib/imap/backup/setup/global_options.rb