Sha256: 30683a18b239394c560bfd9061cb881224cabaeeab4ce3ae1985ddd69777e1be

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

namespace :praxis do
  desc 'Run interactive pry/irb console'
  task :console do
    # Use irb if available (which it almost always is).
    require 'irb'

    Rake::Task['praxis:environment'].invoke

    # Keep IRB.setup from complaining about bad ARGV options
    old_argv = ARGV.dup
    ARGV.clear
    IRB.setup nil
    ARGV.concat(old_argv)

    # Allow reentrant IRB
    IRB.conf[:MAIN_CONTEXT] = IRB::Irb.new.context
    require 'irb/ext/multi-irb'

    # Remove main object from prompt (its stringify is not useful)
    nickname = File.basename(::Praxis::Application.instance.root)
    IRB.conf[:PROMPT][:DEFAULT] = {
      PROMPT_I: "%N(#{nickname}):%03n:%i> ",
      PROMPT_N: "%N(#{nickname}):%03n:%i> ",
      PROMPT_S: "%N(#{nickname}):%03n:%i%l ",
      PROMPT_C: "%N(#{nickname}):%03n:%i* "
    }

    # Disable inefficient, distracting autocomplete
    IRB.conf[:USE_AUTOCOMPLETE] = false

    # Set the IRB main object.
    IRB.irb(nil, Praxis::Application.instance)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
praxis-2.0.pre.36 lib/praxis/tasks/console.rb
praxis-2.0.pre.35 lib/praxis/tasks/console.rb
praxis-2.0.pre.34 lib/praxis/tasks/console.rb
praxis-2.0.pre.33 lib/praxis/tasks/console.rb
praxis-2.0.pre.32 lib/praxis/tasks/console.rb