Class: Belt::CLI::RoutesCommand
- Inherits:
-
Object
- Object
- Belt::CLI::RoutesCommand
- Includes:
- RouteInference, SchemaLoader
- Defined in:
- lib/belt/cli/routes_command.rb,
lib/belt/cli/routes_command/schema_loader.rb,
lib/belt/cli/routes_command/route_inference.rb
Defined Under Namespace
Modules: RouteInference, SchemaLoader
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ RoutesCommand
constructor
A new instance of RoutesCommand.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ RoutesCommand
Returns a new instance of RoutesCommand.
21 22 23 24 |
# File 'lib/belt/cli/routes_command.rb', line 21 def initialize(args) @options = {} (args) end |
Class Method Details
.run(args) ⇒ Object
17 18 19 |
# File 'lib/belt/cli/routes_command.rb', line 17 def self.run(args) new(args).run end |
Instance Method Details
#run ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/belt/cli/routes_command.rb', line 26 def run routes_file = find_routes_file abort 'Error: No routes file found. Expected infrastructure/routes.tf.rb' unless routes_file dsl = load_routes(routes_file) @table_inference = TableInference.new(@options[:tables_file]) routes = collect_routes(dsl) routes = apply_grep(routes) if @options[:grep] warn 'Warning: --output-dir has no effect without --namespace' if @options[:output_dir] && !@options[:namespace] if @options[:namespace] output_ruby(routes, @options[:namespace], routes_file) elsif @options[:format] == 'json' output = { routes: routes } models = load_schema_models(routes_file) output[:models] = models if models.any? puts JSON.pretty_generate(output) else output_concise(routes) end end |