Class: RouteGuard::CLI
- Inherits:
-
Thor
- Object
- Thor
- RouteGuard::CLI
- Defined in:
- lib/route_guard/cli.rb
Class Method Summary collapse
-
.exit_on_failure? ⇒ Boolean
Disable Thor's exit-on-failure behavior by default to control exit statuses.
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
Disable Thor's exit-on-failure behavior by default to control exit statuses
89 90 91 |
# File 'lib/route_guard/cli.rb', line 89 def self.exit_on_failure? true end |
Instance Method Details
#check ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/route_guard/cli.rb', line 17 def check config = build_config inspector = Inspector.new(config) report = inspector.run fmt = ([:format] || "terminal").to_sym io = if [:output] File.open([:output], "w") else $stdout end inspector.format(report, fmt, io) io.close if [:output] exit_status(report, config) end |
#doctor ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/route_guard/cli.rb', line 53 def doctor config = build_config config.strict = true config.fail_on_warning = true inspector = Inspector.new(config) report = inspector.run inspector.format(report, :terminal) exit_status(report, config) end |
#html ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/route_guard/cli.rb', line 74 def html config = build_config config.formatters = [:html] inspector = Inspector.new(config) report = inspector.run output_file = [:output] || "route_guard_report.html" File.open(output_file, "w") do |f| inspector.format(report, :html, f) end puts "HTML report generated at #{output_file}" exit_status(report, config) end |
#json ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/route_guard/cli.rb', line 64 def json config = build_config config.formatters = [:json] inspector = Inspector.new(config) report = inspector.run inspector.format(report, :json) exit_status(report, config) end |
#stats ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/route_guard/cli.rb', line 38 def stats config = build_config config.rules = [:statistics] inspector = Inspector.new(config) report = inspector.run fmt = ([:format] || "terminal").to_sym if fmt == :json inspector.format(report, :json) else inspector.format(report, :terminal) end end |