Sha256: 5cba08a995e667064d598d198cb059a86d43e6a05879b6cc19aff997ac44a3c1

Contents?: true

Size: 1.05 KB

Versions: 16

Compression:

Stored size: 1.05 KB

Contents

require 'forwardable'

require 'byebug/helpers/reflection'
require 'byebug/command_list'

module Byebug
  #
  # Subcommand additions.
  #
  module Subcommands
    def self.included(command)
      command.extend(ClassMethods)
    end

    extend Forwardable
    def_delegators :'self.class', :subcommand_list

    #
    # Delegates to subcommands or prints help if no subcommand specified.
    #
    def execute
      subcmd_name = @match[1]
      return puts(help) unless subcmd_name

      subcmd = subcommand_list.match(subcmd_name)
      raise CommandNotFound.new(subcmd_name, self.class) unless subcmd

      subcmd.new(processor, arguments).execute
    end

    #
    # Class methods added to subcommands
    #
    module ClassMethods
      include Helpers::ReflectionHelper

      #
      # Default help text for a command with subcommands
      #
      def help
        super + subcommand_list.to_s
      end

      #
      # Command's subcommands.
      #
      def subcommand_list
        @subcommand_list ||= CommandList.new(commands)
      end
    end
  end
end

Version data entries

16 entries across 15 versions & 3 rubygems

Version Path
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/byebug-9.1.0/lib/byebug/subcommands.rb
tdiary-5.0.6 vendor/bundle/gems/byebug-9.1.0/lib/byebug/subcommands.rb
byebug-9.1.0 lib/byebug/subcommands.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/byebug-9.0.6/lib/byebug/subcommands.rb
tdiary-5.0.5 vendor/bundle/gems/byebug-9.0.6/lib/byebug/subcommands.rb
tdiary-5.0.4 vendor/bundle/gems/byebug-9.0.6/lib/byebug/subcommands.rb
byebug-9.0.6 lib/byebug/subcommands.rb
byebug-9.0.5 lib/byebug/subcommands.rb
byebug-9.0.4 lib/byebug/subcommands.rb
byebug-9.0.3 lib/byebug/subcommands.rb
byebug-9.0.2 lib/byebug/subcommands.rb
byebug-9.0.1 lib/byebug/subcommands.rb
byebug-9.0.0 lib/byebug/subcommands.rb
byebug-8.2.5 lib/byebug/subcommands.rb
byebug-8.2.4 lib/byebug/subcommands.rb
byebug-8.2.3 lib/byebug/subcommands.rb