Sha256: 7a729ecf51aef0be49a4ea3893e40dee1ee119aa0304f62061b1db4e87f1832a

Contents?: true

Size: 1.08 KB

Versions: 2

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.
      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(self)
      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-4.0.1 lib/command/doctor.rb
cpflow-4.0.0 lib/command/doctor.rb