Sha256: 70dd5f35852beafaef72da716aacb2dd6dbd7106cdd8fb5e724037b4a85918ae

Contents?: true

Size: 952 Bytes

Versions: 3

Compression:

Stored size: 952 Bytes

Contents

# frozen_string_literal: true

module Command
  class Generator < Thor::Group
    include Thor::Actions

    def copy_files
      directory("generator_templates", ".controlplane")
    end

    def self.source_root
      File.expand_path("../", __dir__)
    end
  end

  class Generate < Base
    NAME = "generate"
    DESCRIPTION = "Creates base Control Plane config and template files"
    LONG_DESCRIPTION = <<~DESC
      Creates base Control Plane config and template files
    DESC
    EXAMPLES = <<~EX
      ```sh
      # Creates .controlplane directory with Control Plane config and other templates
      cpl generate
      ```
    EX
    WITH_INFO_HEADER = false

    def call
      if controlplane_directory_exists?
        Shell.warn("The directory '.controlplane' already exists!")
        return
      end

      Generator.start
    end

    private

    def controlplane_directory_exists?
      Dir.exist? ".controlplane"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cpl-1.4.0 lib/command/generate.rb
cpl-1.3.0 lib/command/generate.rb
cpl-1.2.0 lib/command/generate.rb