Sha256: a79ecbc9fc5e88151ef322e88aae1b09e456d7c4acee7118db32eb3a2b56dea7

Contents?: true

Size: 1.74 KB

Versions: 48

Compression:

Stored size: 1.74 KB

Contents

require 'thor'

class Terraspace::CLI::New
  class Sequence < Thor::Group
    include Thor::Actions
    include Terraspace::Util::Logging
    include Helpers

    def self.base_options
      [
        [:examples, type: :boolean, default: false, desc: "Also generate examples"],
        [:force, aliases: %w[y], 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=nil)
      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
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
terraspace-2.2.17 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.16 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.15 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.14 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.13 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.12 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.11 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.10 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.9 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.8 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.7 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.6 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.5 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.4 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.3 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.2 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.1 lib/terraspace/cli/new/sequence.rb
terraspace-2.2.0 lib/terraspace/cli/new/sequence.rb
terraspace-2.1.7 lib/terraspace/cli/new/sequence.rb
terraspace-2.1.6 lib/terraspace/cli/new/sequence.rb