Class: Mode::CLI::Base

Inherits:
Thor
  • Object
show all
Includes:
Helpers
Defined in:
lib/mode/cli/base.rb,
lib/mode/cli/login.rb,
lib/mode/cli/import.rb,
lib/mode/cli/analyze.rb,
lib/mode/cli/connect.rb,
lib/mode/cli/package.rb

Instance Method Summary collapse

Methods included from Helpers

#valid_file?, #valid_table?

Instance Method Details

#analyze(path = nil) ⇒ Object

option :keys, :banner => ‘POSITIONS (ex: 0,2)’, :default => String.new



9
10
11
12
13
14
15
16
17
# File 'lib/mode/cli/analyze.rb', line 9

def analyze(path = nil)
  #keys = options[:keys].split(',').collect(&:strip).collect(&:to_i)

  if field_pos = options[:field]
    Mode::Commands::AnalyzeField.new(path, field_pos, options).execute
  else
    Mode::Commands::AnalyzeSchema.new(path, options).execute
  end
end

#connect(command) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/mode/cli/connect.rb', line 7

def connect(command)
  if ['start', 'stop', 'restart'].include?(command)
    Mode::Commands::Connect.new(command, options).execute
  else
    say "Error: valid commands for connect are start, stop and restart"
  end
rescue => err
  say "Error: #{err.message}"
end

#import(source, table) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/mode/cli/import.rb', line 22

def import(source, table)
  unless valid_table?(table)
    error "Error: Invalid account or table name given"
    return
  end

  , table_name = *table.split('/')
  Mode::Commands::Import.new(source, , table_name).execute
end

#loginObject



8
9
10
# File 'lib/mode/cli/login.rb', line 8

def 
  Mode::Commands::Login.new(options).execute
end

#package(source, package_path) ⇒ Object



7
8
9
10
# File 'lib/mode/cli/package.rb', line 7

def package(source, package_path)
  name = options[:name] || package_path.split(File::Separator).last
  Mode::Commands::Package.new(source, package_path, name, options[:resource_name]).execute
end

#versionObject



11
12
13
# File 'lib/mode/cli/base.rb', line 11

def version
  say "Mode CLI Version #{Mode::VERSION}"
end