Class: RubyJard::Commands::ColorSchemeCommand
- Inherits:
-
Pry::ClassCommand
- Object
- Pry::ClassCommand
- RubyJard::Commands::ColorSchemeCommand
- Includes:
- ColorHelpers
- Defined in:
- lib/ruby_jard/commands/jard/color_scheme_command.rb
Overview
Command used to explore stacktrace.
Instance Method Summary collapse
-
#initialize(context = {}) ⇒ ColorSchemeCommand
constructor
A new instance of ColorSchemeCommand.
- #options(opt) ⇒ Object
- #process ⇒ Object
Methods included from ColorHelpers
#color_decorator, #highlight, #pick_color_scheme, #secondary, #special
Constructor Details
#initialize(context = {}) ⇒ ColorSchemeCommand
Returns a new instance of ColorSchemeCommand.
19 20 21 22 23 |
# File 'lib/ruby_jard/commands/jard/color_scheme_command.rb', line 19 def initialize(context = {}) super(context) @color_schemes = context[:color_schemes] || RubyJard::ColorSchemes @config = context[:config] || RubyJard.config end |
Instance Method Details
#options(opt) ⇒ Object
25 26 27 |
# File 'lib/ruby_jard/commands/jard/color_scheme_command.rb', line 25 def (opt) opt.on :l, :list, 'List all available color schemes' end |
#process ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ruby_jard/commands/jard/color_scheme_command.rb', line 29 def process if opts[:l] if @color_schemes.names.empty? pry_instance.output.puts 'No loaded color schemes' else print_color_schemes end else color_scheme = args.first.to_s.strip if color_scheme.empty? raise Pry::CommandError, 'You must provide a color scheme name. '\ "Please use `#{highlight('jard color-scheme -l')}` to list all color schemes." end if @color_schemes[color_scheme].nil? raise Pry::CommandError, "Color scheme `#{secondary(color_scheme)}` not found. "\ "Please use `#{highlight('jard color-scheme -l')}` to list all color schemes." end @config.color_scheme = color_scheme RubyJard::ControlFlow.dispatch(:list) end end |