Class: Cauchy::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/cauchy/cli.rb

Instance Method Summary collapse

Instance Method Details

#apply(schema_name = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cauchy/cli.rb', line 33

def apply(schema_name = nil)
  verify_project!
  Migrator.migrate(
    client, schema_path, schema_name,
    options.slice('reindex', 'close_index').symbolize_keys
  )
rescue Elastic::CannotUpdateNonDynamicSettingsError => e
  Cauchy.logger.warn e.to_s
  Cauchy.logger.warn 'Provide --close-index in order to perform this update'
rescue MigrationError => e
  Cauchy.logger.warn e.to_s
end

#initObject



20
21
22
# File 'lib/cauchy/cli.rb', line 20

def init
  init_project
end

#new(name) ⇒ Object



25
26
27
28
# File 'lib/cauchy/cli.rb', line 25

def new(name)
  verify_project!
  generate_schema name
end

#status(schema_name = nil) ⇒ Object



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

def status(schema_name = nil)
  verify_project!
  Migrator.status(client, schema_path, schema_name)
rescue MigrationError => e
  Cauchy.logger.warn e.to_s
end

#versionObject



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

def version
  Cauchy.logger.info "Couchy v#{Cauchy::VERSION}"
end