Sha256: 8824e2d5437fbd2a01bb157271153a39c744458196d3241275c7a4ca09b79cb0

Contents?: true

Size: 944 Bytes

Versions: 39

Compression:

Stored size: 944 Bytes

Contents

module Seira
  module Commands
    class Gcloud
      attr_reader :context, :command, :format, :clean_output

      def initialize(command, context:, clean_output:, format:)
        @command = command
        @context = context
        @format = format
        @clean_output = clean_output
      end

      def invoke
        puts "Calling: #{calculated_command.green}" unless clean_output

        if format == :boolean
          system(calculated_command)
        elsif format == :json
          `#{calculated_command}`
        end
      end

      private

      def calculated_command
        @_calculated_command ||= begin
          rv =
            if format == :json
              "gcloud #{command} --format=json"
            else
              "gcloud #{command}"
            end

          unless context.nil?
            rv = "#{rv} --project=#{context[:project]}"
          end

          rv
        end
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
seira-0.9.2 lib/seira/commands/gcloud.rb
seira-0.9.0 lib/seira/commands/gcloud.rb
seira-0.8.3 lib/seira/commands/gcloud.rb
seira-0.8.2 lib/seira/commands/gcloud.rb
seira-0.8.1 lib/seira/commands/gcloud.rb
seira-0.8.0 lib/seira/commands/gcloud.rb
seira-0.7.5 lib/seira/commands/gcloud.rb
seira-0.7.4 lib/seira/commands/gcloud.rb
seira-0.7.3 lib/seira/commands/gcloud.rb
seira-0.7.2 lib/seira/commands/gcloud.rb
seira-0.7.1 lib/seira/commands/gcloud.rb
seira-0.7.0 lib/seira/commands/gcloud.rb
seira-0.6.6 lib/seira/commands/gcloud.rb
seira-0.6.5 lib/seira/commands/gcloud.rb
seira-0.6.4 lib/seira/commands/gcloud.rb
seira-0.6.3 lib/seira/commands/gcloud.rb
seira-0.6.2 lib/seira/commands/gcloud.rb
seira-0.6.1 lib/seira/commands/gcloud.rb
seira-0.6.0 lib/seira/commands/gcloud.rb
seira-0.5.9 lib/seira/commands/gcloud.rb