class Seira::Commands::Gcloud

Attributes

clean_output[R]
command[R]
context[R]
format[R]

Public Class Methods

new(command, context:, clean_output:, format:) click to toggle source
# File lib/seira/commands/gcloud.rb, line 6
def initialize(command, context:, clean_output:, format:)
  @command = command
  @context = context
  @format = format
  @clean_output = clean_output
end

Public Instance Methods

invoke() click to toggle source
# File lib/seira/commands/gcloud.rb, line 13
def invoke
  puts "Calling: #{calculated_command.green}" unless clean_output

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

Private Instance Methods

calculated_command() click to toggle source
# File lib/seira/commands/gcloud.rb, line 25
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