Sha256: 5ecffb8ba2199d6e82125b529279f6bb258a7495b32dcda7d44b25d3f1184e1b

Contents?: true

Size: 927 Bytes

Versions: 3

Compression:

Stored size: 927 Bytes

Contents

module TerraspaceBundler
  class Example < TB::CLI::Base
    def run
      check_mod!
      stack = Exporter::Stacks::Stack.new(mod, stack_options)
      stack.export
      logger.info "Example from vendor/modules/#{@options[:mod]}/examples/#{@src} imported to #{@dest}/#{@name}"
    end

    def stack_options
      @name = @options[:name] || @options[:example]
      @purge = @options[:purge].nil? ? true : @options[:purge]
      @dest = @options[:dest] || "app/stacks"
      @src = @options[:example]
      {
        name: @name,
        src: @src,
        dest: @dest,
        purge: @purge,
      }
    end

    def mod
      lockfile.mods.find { |mod| mod.name == @options[:mod] }
    end

    def check_mod!
      unless mod
        logger.error "ERROR: mod #{@options[:mod]} not found in Terrafile.lock".color(:red)
        exit 1
      end
    end

  private
    def lockfile
      Lockfile.instance
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
terraspace-bundler-0.5.0 lib/terraspace_bundler/example.rb
terraspace-bundler-0.4.4 lib/terraspace_bundler/example.rb
terraspace-bundler-0.4.3 lib/terraspace_bundler/example.rb