Method: Querly::CLI#console

Defined in:
lib/querly/cli.rb

#console(*paths) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/querly/cli.rb', line 70

def console(*paths)
  require 'querly/cli/console'
  home_path = if (path = ENV["QUERLY_HOME"])
                   Pathname(path)
                 else
                   Pathname(Dir.home) + ".querly"
                 end
  home_path.mkdir unless home_path.exist?
  config = config_path.file? ? config(root_option: nil) : nil
  threads = Integer(options[:threads])

  Console.new(
    paths: paths.empty? ? [Pathname.pwd] : paths.map {|path| Pathname(path) },
    history_path: home_path + "history",
    history_size: ENV["QUERLY_HISTORY_SIZE"]&.to_i || 1_000_000,
    config: config,
    threads: threads
  ).start
end