Sha256: fb05f166547aa63dff98e89cbd8698bc147469e4442685766696c9892fc9df71

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 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.
      cpl doctor

      # Runs config validation.
      cpl doctor --validations config

      # Runs templates validation (requires app).
      cpl 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

4 entries across 4 versions & 1 rubygems

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