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.



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

def initialize(args = [], options = {}, config = {})
  super(args, options, config)
  @global_options = config[:shell].base.options

  if @global_options[:config] && File.exist?(@global_options[:config])
    profile = Util.get_profile(@global_options[:config], @global_options[:profile])
    @core = Core.new(profile)
  end
end

Instance Method Details

#columnsObject



45
46
47
# File 'lib/arison/cli.rb', line 45

def columns
  puts_json @core.columns_with_table_name(options[:table])
end

#importObject



52
53
54
55
56
# File 'lib/arison/cli.rb', line 52

def import
  data = (options[:data] ? options[:data] : nil) || Util.parse_json(STDIN.read)
  data = [data] if data.class == Hash
  @core.import(options[:table], data)
end

#infoObject



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

def info
  puts_json @config
end

#query_file(file) ⇒ Object



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

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

#query_inlineObject



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

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

#tablesObject



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

def tables
  puts_json @core.tables
end

#versionObject



64
65
66
# File 'lib/arison/cli.rb', line 64

def version
  puts VERSION
end