Class: RubyJard::Commands::JardCommand

Inherits:
Pry::ClassCommand
  • Object
show all
Defined in:
lib/ruby_jard/commands/jard_command.rb

Overview

Command used to explore stacktrace.

Constant Summary collapse

SUB_COMMANDS =
{
  'show' => RubyJard::Commands::ShowCommand,
  'hide' => RubyJard::Commands::HideCommand,
  'color-scheme' => RubyJard::Commands::ColorSchemeCommand,
  'output' => RubyJard::Commands::OutputCommand,
  'filter' => RubyJard::Commands::FilterCommand
}.freeze

Instance Method Summary collapse

Instance Method Details

#processObject



42
43
44
45
46
47
# File 'lib/ruby_jard/commands/jard_command.rb', line 42

def process
  return if @ran_sub_command
  return if ['-h', '--help'].include?(args.first) || SUB_COMMANDS.keys.include?(args.first)

  pry_instance.output.puts help
end

#subcommands(cmd) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ruby_jard/commands/jard_command.rb', line 30

def subcommands(cmd)
  SUB_COMMANDS.each do |command_name, sub_command|
    cmd.command command_name do |opt|
      opt.description sub_command.description
      opt.run do |_, arguments|
        @ran_sub_command = true
        sub_command.new(context).send(:call_safely, *arguments)
      end
    end
  end
end