Sha256: 820123189c7fdbc555993d347ed9104293b3edb81900d354f75ed6f70354e40c

Contents?: true

Size: 652 Bytes

Versions: 3

Compression:

Stored size: 652 Bytes

Contents

module TFA
  class Console
    def initialize(filename = "tfa")
      @storage = Storage.new(filename)
    end

    def run(arguments)
      command_name = arguments.first
      command_for(command_name).run(arguments - [command_name])
    end

    private

    def command_for(command_name)
      registry[command_name].call
    end

    def registry
      Hash.new { |x, y| lambda { UsageCommand.new(@storage) } }.tap do |commands|
        commands['add'] = lambda { AddCommand.new(@storage) }
        commands['show'] = lambda { ShowCommand.new(@storage) }
        commands['totp'] = lambda { TotpCommand.new(@storage) }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tfa-0.0.6 lib/tfa/console.rb
tfa-0.0.5 lib/tfa/console.rb
tfa-0.0.4 lib/tfa/console.rb