Class: LocalVault::CLI::ErrorPresenter
- Inherits:
-
Object
- Object
- LocalVault::CLI::ErrorPresenter
- Defined in:
- lib/localvault/cli/error_presenter.rb
Defined Under Namespace
Classes: Context
Instance Method Summary collapse
-
#initialize(root_class, argv) ⇒ ErrorPresenter
constructor
A new instance of ErrorPresenter.
- #render(error, io: $stderr) ⇒ Object
Constructor Details
#initialize(root_class, argv) ⇒ ErrorPresenter
Returns a new instance of ErrorPresenter.
8 9 10 11 |
# File 'lib/localvault/cli/error_presenter.rb', line 8 def initialize(root_class, argv) @root_class = root_class @argv = argv.map(&:to_s) end |
Instance Method Details
#render(error, io: $stderr) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/localvault/cli/error_presenter.rb', line 13 def render(error, io: $stderr) @error = error context = @context = resolve_context io.puts error_heading(context) io.puts "Usage: #{usage_for(context)}" render_option_hint(context, io) io.puts io.puts "Try:" suggestions_for(context).first(5).each { |suggestion| io.puts " #{suggestion}" } end |