Support helper method extension API

Offen
#588 0 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

@st0012 arbeitet bereits daran.

Seit 02.7.2023.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Beschreibung

enhancement

In #513, I proposed extension API for commands, but it doesn't cover all the extension needs. For example, Rails defines controller and helpers methods (and these methods too) for its Rails console, which are meant to be used as methods and be chained with other method calls. So they should not be treated as commands.

However, helper methods do share some common needs with commands, like:

  • Feature discovery, e.g. can be listed in the result of show_cmds (or help in the future)
  • Proper registration API and documentation (instead of manually including a module)

So I think we should provide (perhaps similar) extension for helper methods to fulfill such needs.

Details

Using Rails' controller helper as example:

module IRB
  module Helper
    class Controller < Helper::Base
      category "Rails"
      description "Gets a new instance of a controller object."

      def execute
        @controller ||= ApplicationController.new
      end
    end
  end
end

IRB::ExtendedCommandBundle.add_helper(:controller, IRB::Helper::Controller)
Vorherrschende Sprache
Ruby
Sterne
477
Forks
165
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
5

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus ruby/irb

Alle Issues in ruby/irb

Ähnliche Issues

Weitere Issues zu Ruby

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.