Class: Belt::CLI::ContractsCommand

Inherits:
Object
  • Object
show all
Includes:
RoutesCommand::SchemaLoader
Defined in:
lib/belt/cli/contracts_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ ContractsCommand

Returns a new instance of ContractsCommand.



17
18
19
20
# File 'lib/belt/cli/contracts_command.rb', line 17

def initialize(args)
  @options = {}
  parse_options(args)
end

Class Method Details

.run(args) ⇒ Object



13
14
15
# File 'lib/belt/cli/contracts_command.rb', line 13

def self.run(args)
  new(args).run
end

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/belt/cli/contracts_command.rb', line 22

def run
  contracts_file = find_contracts_file
  unless contracts_file
    abort 'Error: No contracts file found. ' \
          'Expected config/contracts.rb (or config/contracts.tf.rb, config/schema.tf.rb)'
  end

  models = load_contracts(contracts_file)

  if @options[:format] == 'json'
    output_json(models)
  else
    output_concise(models)
  end
end