Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new console commands via ConsoleMethods mixin #439

Merged
merged 1 commit into from
Nov 11, 2021

Conversation

jaredcwhite
Copy link
Member

@jaredcwhite jaredcwhite commented Nov 6, 2021

Inspired by Rails' ConsoleMethods technique, this PR adds a Bridgetown::ConsoleMethods module which mixes into IRB's main context. In addition to site, you can now access the collections shorthand, and you can also run reload! which will reload all plugins and reset/reread the site.

Also cool is you can extend ConsoleMethods to add your own commands to the console!

# somewhere in plugins/site_builder.rb:

module ConsoleMethods
  def ruby_rocks
    "MINASWAN!"
  end
end

Bridgetown::ConsoleMethods.include ConsoleMethods
bin/bridgetown c

irb> ruby_rocks
=> "MINASWAN!"

@render
Copy link

render bot commented Nov 6, 2021

@render
Copy link

render bot commented Nov 6, 2021

@jaredcwhite jaredcwhite added the enhancement New feature or request label Nov 6, 2021
@jaredcwhite jaredcwhite merged commit f7491c8 into main Nov 11, 2021
@jaredcwhite jaredcwhite deleted the new-console-methods branch November 11, 2021 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant