Sha256: 39786a9077ff7a725f2781fa93e5b1822ebe1b7c3add99aa4f12bfe40377f704

Contents?: true

Size: 1.02 KB

Versions: 55

Compression:

Stored size: 1.02 KB

Contents

require 'travis/cli'

module Travis
  module CLI
    class Console < ApiCommand
      description "interactive shell; requires `pry`"
      on '-x', '--eval LINE', 'run line of ruby' do |c, line|
        c.instance_eval(line)
        exit
      end

      def run
        ensure_pry

        Object.send(:include, Client::Namespace.new(session))
        hooks = defined?(Pry::Hooks) ? Pry::Hooks.new : {}
        opts = {quiet: true, output: $stdout, hooks: hooks }
        opts.merge!({prompt: prompt}) if prompt
        binding.pry(opts)
      end

      private

      def ensure_pry
        require 'pry'
      rescue LoadError
        msg = [
          'You need to install pry to use Travis CLI console. Try',
          nil,
          '$ (sudo) gem install pry'
        ].join("\n")
        error msg
      end

      def prompt
        if Pry.const_defined? :SIMPLE_PROMPT
          Pry::SIMPLE_PROMPT
        elsif defined?(Pry::Prompt)
          Pry::Prompt[:simple]
        else
          nil
        end
      end
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
travis-1.9.1 lib/travis/cli/console.rb
travis-1.9.1.travis.1223.9 lib/travis/cli/console.rb
travis-1.9.1.travis.1220.9 lib/travis/cli/console.rb
travis-1.9.1.travis.1219.9 lib/travis/cli/console.rb
travis-1.9.1.travis.1216.9 lib/travis/cli/console.rb
travis-1.9.1.travis.1208.9 lib/travis/cli/console.rb
travis-1.9.1.travis.1207.9 lib/travis/cli/console.rb
travis-1.9.1.travis.1206.9 lib/travis/cli/console.rb
travis-1.9.1.travis.1205.9 lib/travis/cli/console.rb
travis-1.9.0 lib/travis/cli/console.rb
travis-1.9.1.travis.1201.9 lib/travis/cli/console.rb
travis-1.8.14.travis.1200.9 lib/travis/cli/console.rb
travis-1.8.14.travis.1199.9 lib/travis/cli/console.rb
travis-1.8.14.travis.1198.9 lib/travis/cli/console.rb
travis-1.8.14.travis.1197.9 lib/travis/cli/console.rb
travis-1.8.14.travis.1195.9 lib/travis/cli/console.rb
travis-1.8.14.travis.1192.9 lib/travis/cli/console.rb
travis-1.8.14.travis.1186.9 lib/travis/cli/console.rb
travis-1.8.14.travis.1184.9 lib/travis/cli/console.rb
travis-1.8.14.travis.1183.9 lib/travis/cli/console.rb