Sha256: d44691d3fab70743864bd55d60aaf68b45ac00bf7a6dc6bbda16b1655695f6c5

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 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 'pp'

require_relative '../shared'

GoodData::CLI.module_eval do
  desc 'Interactive session with gooddata sdk loaded'
  command :console do |c|
    c.action do |global_options, _options, _args|
      username = global_options[:username]
      fail ArgumentError, 'No username specified' if username.nil? || username.empty?

      password = global_options[:password]
      fail ArgumentError, 'No password specified' if password.nil? || password.empty?

      pid = global_options[:project_id]
      fail ArgumentError, 'No project specified' if pid.nil?

      client = GoodData.connect username, password

      proj = GoodData::Project[pid, :client => client]

      GoodData.with_project(proj, :client => client) do |project|
        fail ArgumentError, 'Wrong project specified' if project.nil?

        puts "Use 'exit' to quit the live session. Use 'q' to jump out of displaying a large output."
        binding.pry(:quiet => true, # rubocop:disable Lint/Debugger
                    :prompt => [proc do |_target_self, _nest_level, _pry|
                      'sdk_live_session: '
                    end])
      end
      client.disconnect
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gooddata-0.6.24 lib/gooddata/cli/commands/console_cmd.rb
gooddata-0.6.23 lib/gooddata/cli/commands/console_cmd.rb
gooddata-0.6.22 lib/gooddata/cli/commands/console_cmd.rb