Class: Arison::CLI

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

Instance Method Summary collapse

Constructor Details

#initialize(args = [], options = {}, config = {}) ⇒ CLI

Returns a new instance of CLI.



18
19
20
21
22
23
24
# File 'lib/arison/cli.rb', line 18

def initialize(args = [], options = {}, config = {})
  super(args, options, config)
  @global_options = config[:shell].base.options
  @config = YAML.load_file(@global_options['config'])
  profile = @config[@global_options['profile']]
  @core = Core.new(profile)
end

Instance Method Details

#columns(table_name) ⇒ Object



43
44
45
# File 'lib/arison/cli.rb', line 43

def columns(table_name)
  puts_json @core.columns_with_table_name(table_name)
end

#import(table) ⇒ Object



48
49
50
51
52
# File 'lib/arison/cli.rb', line 48

def import(table)
  data = @core.parse_json(STDIN.read)
  @core.create_table(table, data)
  @core.import(table, data)
end

#infoObject



55
56
57
# File 'lib/arison/cli.rb', line 55

def info
  puts_json @config
end

#query_file(file) ⇒ Object



33
34
35
# File 'lib/arison/cli.rb', line 33

def query_file(file)
  puts_json @core.query(File.read(file))
end

#query_inlineObject



28
29
30
# File 'lib/arison/cli.rb', line 28

def query_inline
  puts_json @core.query(options['query'])
end

#tablesObject



38
39
40
# File 'lib/arison/cli.rb', line 38

def tables
  puts_json @core.tables
end

#versionObject



60
61
62
# File 'lib/arison/cli.rb', line 60

def version
  puts VERSION
end