Class: Arpry::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/arpry/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



3
4
5
6
7
# File 'lib/arpry/cli.rb', line 3

def initialize(argv)
  @argv = argv
  @database = nil
  @adapter = nil
end

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/arpry/cli.rb', line 9

def run
  parse_options

  namespace = ClassFactory.create(@params)
  ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer = true if @params[:adapter] == 'sqlite3'

  prompts = [
    proc do |_obj, nest_level, pry|
      "[#{pry.input_ring.size}] arpry#{":#{nest_level}" unless nest_level.zero?}> "
    end,
    proc do |_obj, nest_level, pry|
      "[#{pry.input_ring.size}] arpry#{":#{nest_level}" unless nest_level.zero?}* "
    end,
  ]

  binding.pry(namespace, prompt: prompts)

  return 0
end