Method: InspecPlugins::Init::CLI#plugin

Defined in:
lib/plugins/inspec-init/lib/inspec-init/cli_plugin.rb

#plugin(plugin_name) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/plugins/inspec-init/lib/inspec-init/cli_plugin.rb', line 28

def plugin(plugin_name)
  plugin_type = determine_plugin_type(plugin_name)
  snake_case = plugin_name.tr("-", "_")

  template_vars = {
    name: plugin_name,
    plugin_name: plugin_name,
    snake_case: snake_case,
  }.merge(plugin_vars_from_opts)

  template_path = File.join("plugins", plugin_type + "-plugin-template")

  render_opts = {
    templates_path: TEMPLATES_PATH,
    overwrite: options[:overwrite],
    file_rename_map: make_rename_map(plugin_type, plugin_name, snake_case),
    skip_files: make_skip_list,
  }
  renderer = InspecPlugins::Init::Renderer.new(ui, render_opts)

  renderer.render_with_values(template_path, plugin_type + " plugin", template_vars)
end