Class: Kamal::Lint::CLI
- Inherits:
-
Thor
- Object
- Thor
- Kamal::Lint::CLI
- Defined in:
- lib/kamal/lint/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
8 9 10 |
# File 'lib/kamal/lint/cli.rb', line 8 def self.exit_on_failure? true end |
Instance Method Details
#lint ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/kamal/lint/cli.rb', line 33 def lint runner = Runner.new( config_file: [:config_file], destination: [:destination], kamal_version: [:"kamal-version"], fix: [:fix], include_kamal_errors: [:"include-kamal-errors"] ) result = runner.call formatter = build_formatter([:format], [:no_color]) formatter.render(result) formatter.render_fix_summary(result) if [:fix] exit(result.exit_code(fail_on: [:fail_on].to_sym)) rescue ConfigNotFoundError => e warn "kamal-lint: #{e.}" exit(2) end |
#list_checks ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/kamal/lint/cli.rb', line 54 def list_checks registry = Lint.registry format = [:format] if format == "json" require "json" payload = registry.all.map do |check| { id: check.id, severity: check.severity.to_s, title: check.title, since: check.since, until_version: check.until_version, autofixable: check.autofixable } end puts JSON.pretty_generate(payload) else puts "#{"ID".ljust(38)} #{"SEVERITY".ljust(9)} #{"SINCE".ljust(8)} TITLE" puts "-" * 110 registry.all.each do |check| line = [ check.id.to_s.ljust(38), check.severity.to_s.ljust(9), (check.since || "—").to_s.ljust(8), check.title.to_s ].join(" ") line += " (autofixable)" if check.autofixable puts line end puts puts "Total: #{registry.all.size} checks" end end |