Skip to content

Instantly share code, notes, and snippets.

@korczis
Created March 19, 2014 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korczis/9638946 to your computer and use it in GitHub Desktop.
Save korczis/9638946 to your computer and use it in GitHub Desktop.
Hopefully fixed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment