Class: Jekyll::Commands::AgentAudit
- Inherits:
-
Jekyll::Command
- Object
- Jekyll::Command
- Jekyll::Commands::AgentAudit
- Defined in:
- lib/jekyll/agent_audit/command.rb
Defined Under Namespace
Modules: CommandParser, ParserErrors
Class Method Summary collapse
Class Method Details
.init_with_program(prog) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jekyll/agent_audit/command.rb', line 29 def init_with_program(prog) prog.command(:"agent:audit") do |command| command.singleton_class.prepend(CommandParser) command.syntax "agent:audit [options]" command.description "Audit rendered publication output" (command) command.option "format", "--format FORMAT", "console or json" command.option "output", "--output PATH", "Write the report atomically" command.option "fail_on", "--fail-on LEVEL", "error, warning, or none" command.option "only", "--only RULES", "Comma-separated rule IDs" command.option "list_rules", "--list-rules", "List available rules" command.option "explain", "--explain RULE", "Explain a rule" command.option "verbose", "--verbose", "Include skipped checks" command.action { |_, | process() } end end |
.process(options) ⇒ Object
46 47 48 49 50 51 52 53 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 |
# File 'lib/jekyll/agent_audit/command.rb', line 46 def process() = .transform_keys(&:to_s) validate_only!() if ["list_rules"] write_output(render_rules(), ["output"]) return 0 end if ["explain"] write_output(explain(["explain"], ), ["output"]) return 0 end report = run_audit() format = ["format"] || report.to_h.dig("run", "effective_configuration", "format") || "console" output = render_report(report, format) write_output(output, ["output"]) exit(report_exit_code(report)) rescue Jekyll::AgentAudit::ConfigurationError, ArgumentError => e if && ["format"] == "json" write_output(render_error(e), ["output"]) else warn "jekyll-agent-audit: #{e.}" end exit 2 rescue SystemExit raise rescue StandardError => e if && ["format"] == "json" write_output(render_error(e), ["output"]) else warn "jekyll-agent-audit: #{e.}" end exit 2 end |