Class: Aws::Templates::Cli::Interface

Inherits:
Thor
  • Object
show all
Defined in:
lib/aws/templates/cli/interface.rb

Overview

Templates CLI

The class provides command-line utilities to use cloud templates and artifacts without knowledge of Ruby directly from command line. Commands:

  • render - It is used to setup and execute rendering of a single artifact. Also, different

    formatters supported for output. By default, render output is not formatted
    at all and is returned as is. JSON formatter is available out-of-box.
    
  • document - provide online documentation for selected artifact optionally using specific

    documentation generator
    

Instance Method Summary collapse

Instance Method Details

#document(artifact_path) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/aws/templates/cli/interface.rb', line 64

def document(artifact_path)
  artifact = Templates::Utils.lookup_module(artifact_path)
  generator = Templates::Utils.lookup_module(options[:generator])
  params = options[:parameters] && ::JSON.parse(options[:parameters], symbolize_names: true)

  say(generator.show(artifact, params))
end

#render(artifact_path) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/aws/templates/cli/interface.rb', line 40

def render(artifact_path)
  say _format(
    Templates::Utils.lookup_module(artifact_path),
    Templates::Utils.lookup_module(options[:render]),
    Aws::Templates::Cli::Formatter.format_as(options[:format]),
    ::JSON.parse(options[:options] || _as_string(STDIN), symbolize_names: true)
  )
end