Class: Ath::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/ath/shell.rb

Constant Summary collapse

HISTORY_FILE =
File.join(ENV.fetch('HOME', '.'), '.ath_history')
HISTSIZE =
1000

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(athena: Aws::Athena::Client.new, s3: Aws::S3::Client.new, output_location:, database: nil, pager: nil, options: {}) ⇒ Shell

Returns a new instance of Shell.



9
10
11
12
13
14
# File 'lib/ath/shell.rb', line 9

def initialize(athena: Aws::Athena::Client.new, s3: Aws::S3::Client.new, output_location:, database: nil, pager: nil, options: {})
  @driver = Ath::Driver.new(athena: athena, s3: s3, output_location: output_location, database: database, options: options)
  @pager = pager
  @options = options
  @scanner = Ath::Scanner.new(shell: self)
end

Instance Attribute Details

#driverObject (readonly)

Returns the value of attribute driver.



5
6
7
# File 'lib/ath/shell.rb', line 5

def driver
  @driver
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/ath/shell.rb', line 6

def options
  @options
end

#pagerObject

Returns the value of attribute pager.



7
8
9
# File 'lib/ath/shell.rb', line 7

def pager
  @pager
end

Instance Method Details

#oneshot(query) ⇒ Object



26
27
28
# File 'lib/ath/shell.rb', line 26

def oneshot(query)
  execute_query(query)
end

#startObject



16
17
18
19
20
21
22
23
24
# File 'lib/ath/shell.rb', line 16

def start
  load_history

  while line = Readline.readline(prompt, true)
    execute_query(line)
  end
ensure
  save_history
end