Skip to content

Commit

Permalink
Add an interactive console for users as well (#21803)
Browse files Browse the repository at this point in the history
* Add an interactive console for users as well

* Proposed documentation

* Apply copy suggestions.

* Format copy.

---------

Co-authored-by: Roger Oba <rogerluan.oba@gmail.com>
  • Loading branch information
lacostej and rogerluan committed Jan 13, 2024
1 parent fb8d468 commit 21d0e79
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
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鈥檙e 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

0 comments on commit 21d0e79

Please sign in to comment.