Class: Moonshot::Commands::GenerateTemplate
- Inherits:
-
Moonshot::Command
- Object
- Moonshot::Command
- Moonshot::Commands::GenerateTemplate
- Defined in:
- lib/moonshot/commands/generate_template.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize ⇒ GenerateTemplate
constructor
A new instance of GenerateTemplate.
- #parser ⇒ Object
Methods inherited from Moonshot::Command
Constructor Details
#initialize ⇒ GenerateTemplate
Returns a new instance of GenerateTemplate.
9 10 11 12 |
# File 'lib/moonshot/commands/generate_template.rb', line 9 def initialize(*) super @parameters = {} end |
Instance Method Details
#execute ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/moonshot/commands/generate_template.rb', line 37 def execute ::Moonshot::DynamicTemplate.new( source: @source, parameters: @parameters, destination: @destination ).process end |
#parser ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/moonshot/commands/generate_template.rb', line 14 def parser parser = super parser.on('--source SOURCE_FILE', 'The ERB template file.') do |v| @source = v end parser.on('--parameter KEY=VALUE', '-PKEY=VALUE', 'Specify Stack Parameter on the command line') do |v| data = v.split('=', 2) unless data.size == 2 raise "Invalid parameter format '#{v}',"\ 'expected KEY=VALUE (e.g. MyTemplateParameter=12)' end @parameters[data[0]] = data[1] end parser.on('--destination DESTINATION_FILE', 'Destionation file.') do |v| @destination = v end end |