Sha256: 613d4bd7d39a53e4f7a0611d5aec15f680559e8e3797c8c66b1776100d2f8d15

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

# encoding: UTF-8

require 'gli'
require 'pp'

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::Command::Auth.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

7 entries across 7 versions & 1 rubygems

Version Path
gooddata-0.6.7 lib/gooddata/cli/hooks.rb
gooddata-0.6.6 lib/gooddata/cli/hooks.rb
gooddata-0.6.5 lib/gooddata/cli/hooks.rb
gooddata-0.6.4 lib/gooddata/cli/hooks.rb
gooddata-0.6.3 lib/gooddata/cli/hooks.rb
gooddata-0.6.2 lib/gooddata/cli/hooks.rb
gooddata-0.6.0 lib/gooddata/cli/hooks.rb