Sha256: 11ca7358cd616759b0706f54047126d5100d177f1ca29838a7a627cd68a9bdb6

Contents?: true

Size: 1.53 KB

Versions: 29

Compression:

Stored size: 1.53 KB

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

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] || creds[:token] if token.nil?

    global[:token] = token if global[:token].nil?
    if global[:login].nil?
      global[:login] = username
      global['login'] = username
    end
    if global[:password].nil?
      global[:password] = password
      global['password'] = password
    end
    # 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

29 entries across 29 versions & 2 rubygems

Version Path
gooddata-edge-0.6.27.edge lib/gooddata/cli/hooks.rb
gooddata-0.6.49 lib/gooddata/cli/hooks.rb
gooddata-0.6.48 lib/gooddata/cli/hooks.rb
gooddata-0.6.47 lib/gooddata/cli/hooks.rb
gooddata-0.6.46 lib/gooddata/cli/hooks.rb
gooddata-0.6.45 lib/gooddata/cli/hooks.rb
gooddata-0.6.44 lib/gooddata/cli/hooks.rb
gooddata-0.6.43 lib/gooddata/cli/hooks.rb
gooddata-0.6.42 lib/gooddata/cli/hooks.rb
gooddata-0.6.41 lib/gooddata/cli/hooks.rb
gooddata-0.6.40 lib/gooddata/cli/hooks.rb
gooddata-0.6.39 lib/gooddata/cli/hooks.rb
gooddata-0.6.38 lib/gooddata/cli/hooks.rb
gooddata-0.6.37 lib/gooddata/cli/hooks.rb
gooddata-0.6.36 lib/gooddata/cli/hooks.rb
gooddata-0.6.35 lib/gooddata/cli/hooks.rb
gooddata-0.6.34 lib/gooddata/cli/hooks.rb
gooddata-0.6.33 lib/gooddata/cli/hooks.rb
gooddata-0.6.32 lib/gooddata/cli/hooks.rb
gooddata-0.6.31 lib/gooddata/cli/hooks.rb