Sha256: 53881817987be2222427fbd70d439240119bbe9265c2d4a9ba86f6e0600d3bdb

Contents?: true

Size: 1.61 KB

Versions: 4

Compression:

Stored size: 1.61 KB

Contents

require 'rubygems'
require 'terminal-table/import'

module VMC::Cli

  module Command

    class Base
      attr_reader :no_prompt, :prompt_ok

      def initialize(options={})
        @options = options.dup
        @no_prompt = @options[:noprompts]
        @prompt_ok = !no_prompt

        # Suppress colorize on Windows systems for now.
        if WINDOWS
          VMC::Cli::Config.colorize = false
        end
      end

      def client
        return @client if @client
        @client = VMC::Client.new(target_url, auth_token)
        @client.trace = VMC::Cli::Config.trace if VMC::Cli::Config.trace
        @client.proxy_for @options[:proxy] if @options[:proxy]
        @client
      end

      def client_info
        @client_info ||= client.info
      end

      def target_url
        @target_url ||= VMC::Cli::Config.target_url
      end

      def target_base
        @target_base ||= VMC::Cli::Config.suggest_url
      end

      def auth_token
        @auth_token ||= VMC::Cli::Config.auth_token
      end

      def runtimes_info
        return @runtimes if @runtimes
        info = client_info
        @runtimes = {}
        if info[:frameworks]
          info[:frameworks].each_value do |f|
            next unless f[:runtimes]
            f[:runtimes].each { |r| @runtimes[r[:name]] = r}
          end
        end
        @runtimes
      end

      def frameworks_info
        return @frameworks if @frameworks
        info = client_info
        @frameworks = []
        if info[:frameworks]
          info[:frameworks].each_value { |f| @frameworks << [f[:name]] }
        end
        @frameworks
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
af-0.3.13.beta.5 lib/cli/commands/base.rb
vmc-0.3.13.beta.5 lib/cli/commands/base.rb
vmc-0.3.13.beta.4 lib/cli/commands/base.rb
vmc-0.3.13.beta.3 lib/cli/commands/base.rb