Sha256: f5db90a6addd5a3a074b1ef6eaeaa09ac29433a2afe42d40a0ecf4d8b350f08b

Contents?: true

Size: 1010 Bytes

Versions: 4

Compression:

Stored size: 1010 Bytes

Contents

# frozen_string_literal: true

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

    def copy_files
      directory("generator_templates", ".controlplane", verbose: ENV.fetch("HIDE_COMMAND_OUTPUT", nil) != "true")
    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

4 entries across 4 versions & 1 rubygems

Version Path
cpl-2.2.4 lib/command/generate.rb
cpl-2.2.2 lib/command/generate.rb
cpl-2.2.1 lib/command/generate.rb
cpl-2.2.0 lib/command/generate.rb