Sha256: 8f529a7004b5222dd3f5c97ced0e7611271ca166a01c55ccdf589c1d243a4d7d

Contents?: true

Size: 1.22 KB

Versions: 8

Compression:

Stored size: 1.22 KB

Contents

# encoding: UTF-8

require 'gli'
require 'pp'

require_relative '../helpers/auth_helpers'

GoodData::CLI.module_eval do
  pre do |global, _command, _options, _args|
    require 'logger'
    GoodData.logger = Logger.new(STDOUT) if global[:l]
    username = global[:username]
    password = global[:password]
    token = global[:token]

    creds = GoodData::Helpers::AuthHelper.read_credentials

    username = creds[:username] if username.nil?
    password = creds[:password] if password.nil?
    token = creds[:auth_token] if token.nil?

    global[:token] = token if global[:token].nil?
    global[:login] = username if global[:login].nil?
    global[:password] = password if global[:password].nil?
    # Pre logic here
    # Return true to proceed; false to abort and not call the
    # chosen command
    # Use skips_pre before a command to skip this block
    # on that command only
    true
  end

  post do |_global, _command, _options, _args|
    # Post logic here
    # Use skips_post before a command to skip this
    # block on that command only
  end

  on_error do |_exception|
    # Error logic here
    # return false to skip default error handling
    # binding.pry
    # pp exception.backtrace
    # pp exception
    true
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gooddata-0.6.18 lib/gooddata/cli/hooks.rb
gooddata-0.6.17 lib/gooddata/cli/hooks.rb
gooddata-0.6.16 lib/gooddata/cli/hooks.rb
gooddata-0.6.15 lib/gooddata/cli/hooks.rb
gooddata-0.6.14 lib/gooddata/cli/hooks.rb
gooddata-0.6.13 lib/gooddata/cli/hooks.rb
gooddata-0.6.12 lib/gooddata/cli/hooks.rb
gooddata-0.6.11 lib/gooddata/cli/hooks.rb