Skip to content

Instantly share code, notes, and snippets.

@domcleal
Created April 5, 2017 16:35
Show Gist options
  • Save domcleal/5c1c9e892d175ac351d894204e7069db to your computer and use it in GitHub Desktop.
Save domcleal/5c1c9e892d175ac351d894204e7069db to your computer and use it in GitHub Desktop.
fail("Usage: move_types_to_parameters.rb MANIFEST_PP CLASS_NAME") if ARGV.length != 2
original_params = File.read(ARGV[0]).lines.map do |line|
$1 if line =~ /\A \$(\w+)\s+=.*,$/
end.compact
require 'kafo_parsers/puppet_strings_module_parser'
hash = KafoParsers::PuppetStringsModuleParser.parse(ARGV.first)
original_params.each do |param|
type = hash[:types].fetch(param, 'Any')
puts " %s $%s = $::%s::params::%s," % [type, param, ARGV[1], param]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment