Sha256: 7cb577f32c0bcb5ca7f37c3ac0f0d626bcb16c6cc09bff63ae98088758d8dfc9

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'pastel'
require_relative '../../../command'

module Sfctl
  module Commands
    class Time
      class Providers
        class Get < Sfctl::Command
          def initialize(options)
            @options = options
            @pastel = Pastel.new(enabled: !@options['no-color'])
          end

          def execute(output: $stdout)
            read_link_config

            PROVIDERS_LIST.each do |provider|
              read(provider, output)
            end
          rescue TTY::Config::ReadError
            output.puts @pastel.yellow('Please initialize time before continue.')
          end

          private

          def read(provider, output)
            info = config.fetch("providers.#{provider}")
            if info.nil?
              output.puts @pastel.yellow("Provider #{provider} is not set.")
            else
              output.puts "Provider: #{@pastel.cyan(provider)}"
              info.each_key do |k|
                output.puts "  #{k.upcase}: #{info[k]}"
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sfctl-0.0.1 lib/sfctl/commands/time/providers/get.rb