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 an interactive console for users as well #21803

Merged
merged 4 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions ToolsAndDebugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

For detailed instructions on how to get started with contributing to _fastlane_, first check out [YourFirstPR.md][first-pr] and [Testing.md](Testing.md). This guide will focus on more advanced instructions on how to debug _fastlane_ and _spaceship_ issues and work on patches.

## Experiment with the _fastlane_ internals

Open a _fastlane_ console by running `fastlane console` inside or outside your project.

This will allow you to invoke any of the _fastlane_ modules and classes and test their behavior.

## Debug using [pry](https://pry.github.io/)

Before you’re able to use [pry](https://pry.github.io/), make sure to have completed the [YourFirstPR.md][first-pr] setup part, as this will install all required development dependencies.
Expand Down
9 changes: 9 additions & 0 deletions fastlane/lib/fastlane/commands_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@ def run
end
end

command :console do |c|
c.syntax = 'fastlane console'
c.description = 'Opens an interactive developer console'
c.action do |args, options|
require 'fastlane/console'
Fastlane::Console.execute(args, options)
end
end

command :enable_auto_complete do |c|
c.syntax = 'fastlane enable_auto_complete'
c.description = 'Enable tab auto completion'
Expand Down
24 changes: 24 additions & 0 deletions fastlane/lib/fastlane/console.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'irb'

module Fastlane
# Opens an interactive developer console
class Console
def self.execute(args, options)
ARGV.clear
IRB.setup(nil)
@irb = IRB::Irb.new(nil)
IRB.conf[:MAIN_CONTEXT] = @irb.context
IRB.conf[:PROMPT][:FASTLANE] = IRB.conf[:PROMPT][:SIMPLE].dup
IRB.conf[:PROMPT][:FASTLANE][:RETURN] = "%s\n"
@irb.context.prompt_mode = :FASTLANE
@irb.context.workspace = IRB::WorkSpace.new(binding)
trap('INT') do
@irb.signal_handle
end

UI.message('Welcome to fastlane interactive!')

catch(:IRB_EXIT) { @irb.eval_input }
end
end
end