Sha256: 648d3cbc377bf101c1d28d15fe9a6727d8236a72c83dac49455e9d3e70bc6a19
Contents?: true
Size: 2 KB
Versions: 19
Compression:
Stored size: 2 KB
Contents
require 'thor' class Terraspace::CLI::New class Sequence < Thor::Group include Thor::Actions include Helper def self.base_options [ [:examples, type: :boolean, default: false, desc: "Also generate examples"], [:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"], [:lang, default: "hcl", desc: "Language to use: HCL/ERB or Ruby DSL"], [:plugin, aliases: %w[p], default: "aws", desc: "Cloud Plugin. Supports: aws, google"], [:test, type: :boolean, desc: "Whether or not to generate tests"], [:plugin_gem, desc: "Use if provider gem name doesnt follow terraspace_plugin_XXX naming convention. Must specify both --plugin and --plugin-name option"], ] end def self.component_options [ [:project_name, desc: "Only used internally", hide: true], ] end base_options.each { |args| class_option(*args) } argument :name private def component_args(component_name, project_name) args = [ component_name, "--project-name", project_name, ] args += ["--lang", @options[:lang]] if @options[:lang] args += ["--plugin", @options[:plugin]] if @options[:plugin] args += ["--plugin-gem", @options[:plugin_gem]] if @options[:plugin_gem] args += @options[:test] ? ["--test"] : ["--no-test"] # since test may be true by default args += ["--examples"] if @options[:examples] args += ["--force"] if @options[:force] args end # friendly method def plugin_template_source(template, type) source = Source::Plugin.new(self, @options) source.set_source_paths(template, type) end # A generator script hook to allow for further customizations # The dest folder like app/modules/demo is provided as a first argument to the command. def run_script(script, dest) command = "#{script} #{dest}" puts "Running: #{command}" unless ENV['TS_GENERATOR_MUTE'] system(command) end end end
Version data entries
19 entries across 19 versions & 1 rubygems