Class: Belt::CLI::TablesCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/belt/cli/tables_command.rb

Constant Summary collapse

MODULE_DIR =
'infrastructure/modules/app'
MODELS_DIR =
'lambda/models'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(quiet: false) ⇒ TablesCommand

Returns a new instance of TablesCommand.



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

def initialize(quiet: false)
  @quiet = quiet
end

Class Method Details

.run(args) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/belt/cli/tables_command.rb', line 13

def self.run(args)
  # Environment argument accepted for backwards compatibility but unused —
  # dynamodb.tf lives in infrastructure/modules/app and uses var.environment.
  EnvResolver.resolve(args)

  new.run
end

.sync_all_environmentsObject

Automatically sync dynamodb.tf in the app module. Called by generators after creating/updating model files.



23
24
25
26
27
# File 'lib/belt/cli/tables_command.rb', line 23

def self.sync_all_environments
  return unless Dir.exist?(MODELS_DIR)

  new(quiet: true).run
end

Instance Method Details

#runObject



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

def run
  validate!
  models = parse_models
  if models.empty?
    puts "No models found in #{MODELS_DIR}/" unless @quiet
    return
  end

  generate_dynamodb_tf(models)
end