Sha256: ce611561f4d9d4f7854c5835315977538c1a4acfc1c105389c6e1792e1282bb5

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

class Terraspace::CLI::New::Plugin
  class Ci < Terraspace::CLI::New::Sequence
    include Helper

    argument :name

    def self.options
      [
        [:force, aliases: %w[y], type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
        [:pr, type: :boolean, desc: "Generate pr code also. Most CI systems don't have PR support"],
      ]
    end
    options.each { |args| class_option(*args) }

    def create_plugin
      puts "=> Creating new ci plugin: #{name}"
      core_template_source("plugin/ci")
      exclude_pattern = "pr\.rb" unless options[:pr]
      directory ".", "terraspace_ci_#{name}", exclude_pattern: exclude_pattern
    end

    def finish_message
      files = [
        "#{gem_name}.gemspec",
        "lib/#{gem_name}.rb",
        "lib/#{gem_name}/vars.rb",
        "lib/#{gem_name}/interface.rb",
        "README.md",
      ]
      files << "lib/#{gem_name}/pr.rb" if @options[:pr]
      files.sort!
      list = files.map { |file| "    #{file}" }.join("\n")
      puts <<~EOL
      Files in #{gem_name} to review and update:

      #{list}
      EOL
    end

  private
    def gem_name
      "terraspace_ci_#{name}"
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
terraspace-2.0.3 lib/terraspace/cli/new/plugin/ci.rb
terraspace-2.0.2 lib/terraspace/cli/new/plugin/ci.rb
terraspace-2.0.1 lib/terraspace/cli/new/plugin/ci.rb
terraspace-2.0.0 lib/terraspace/cli/new/plugin/ci.rb