class Aws::Templates::Cli::Interface
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
Public Instance Methods
document(artifact_path)
click to toggle source
# 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)
click to toggle source
# 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
Private Instance Methods
_as_string(obj)
click to toggle source
# File lib/aws/templates/cli/interface.rb, line 78 def _as_string(obj) if obj.respond_to?(:to_str) obj.to_str elsif obj.respond_to?(:to_io) obj.to_io.read elsif obj.respond_to?(:read) obj.read else obj.to_s end end
_format(artifact, render, format, artifact_options)
click to toggle source
# File lib/aws/templates/cli/interface.rb, line 74 def _format(artifact, render, format, artifact_options) format.format(render.view_for(artifact.new(artifact_options)).to_rendered) end