Sha256: a5168917987f83e716d0b2d99b7be524a6ea9a2b45a84482e0642b4516e6087d

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module Command
  class Doctor < Base
    NAME = "doctor"
    OPTIONS = [
      validations_option,
      app_option
    ].freeze
    DESCRIPTION = "Runs validations"
    LONG_DESCRIPTION = <<~DESC
      - Runs validations
    DESC
    EXAMPLES = <<~EX
      ```sh
      # Runs all validations that don't require additional options by default.
      cpflow doctor

      # Runs config validation.
      cpflow doctor --validations config

      # Runs templates validation (requires app).
      cpflow doctor --validations templates -a $APP_NAME
      ```
    EX
    VALIDATIONS = [].freeze

    def call
      validations = config.options[:validations].split(",")
      ensure_required_options!(validations)

      doctor_service = DoctorService.new(config)
      doctor_service.run_validations(validations)
    end

    private

    def ensure_required_options!(validations)
      validations.each do |validation|
        case validation
        when "templates"
          raise "App is required for templates validation." unless config.app
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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