lib/travis/cli/api_command.rb in travis-1.0.3 vs lib/travis/cli/api_command.rb in travis-1.1.0

- old
+ new

@@ -10,10 +10,17 @@ on('-e', '--api-endpoint URL', 'Travis API server to talk to') on('--pro', "short-cut for --api-endpoint '#{Travis::Client::PRO_URI}'") { |c,_| c.api_endpoint = Travis::Client::PRO_URI } on('--org', "short-cut for --api-endpoint '#{Travis::Client::ORG_URI}'") { |c,_| c.api_endpoint = Travis::Client::ORG_URI } on('-t', '--token [ACCESS_TOKEN]', 'access token to use') { |c, t| c.access_token = t } + on('--debug', 'show API requests') do |c,_| + c.session.instrument do |info, request| + c.debug(info) + request.call + end + end + def initialize(*) @session = Travis::Client.new super end @@ -40,9 +47,24 @@ api_endpoint == detected_endpoint end def authenticate error "not logged in, please run #{command("login#{endpoint_option}")}" if access_token.nil? + end + + def sync(block = true, dot = '.') + user.sync + + steps = count = 1 + while block and user.reload.syncing? + count += 1 + sleep(1) + + if count % steps == 0 + steps = count/10 + 1 + output.print dot + end + end end private def detected_endpoint