Sha256: 734a10c7bbc5c719fcfb3cf5dbb3f7d938e993c0a3dd4d4711bcca34fa054997

Contents?: true

Size: 1013 Bytes

Versions: 2

Compression:

Stored size: 1013 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
      cpflow 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

2 entries across 2 versions & 1 rubygems

Version Path
cpflow-3.0.1 lib/command/generate.rb
cpflow-3.0.0 lib/command/generate.rb