Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Commit 0132771

Browse files
committed
Provide an "on_process_run" callback
1 parent cc7487a commit 0132771

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/net/ssh/shell.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def initialize(session, shell=:default)
1919
@state = :closed
2020
@processes = []
2121
@when_open = []
22+
@on_process_run = nil
2223
@default_process_class = Net::SSH::Shell::Process
2324
open
2425
end
@@ -62,6 +63,10 @@ def opening?
6263
!open? && !closed?
6364
end
6465

66+
def on_process_run(&callback)
67+
@on_process_run = callback
68+
end
69+
6570
def execute(command, klass=nil, &callback)
6671
klass ||= default_process_class
6772
process = klass.new(self, command, callback)
@@ -113,7 +118,11 @@ def on_channel_close(channel)
113118
private
114119

115120
def run_next_process
116-
processes.first.run if processes.any?
121+
if processes.any?
122+
process = processes.first
123+
@on_process_run.call(process) if @on_process_run
124+
process.run
125+
end
117126
end
118127

119128
def open_succeeded(channel)

0 commit comments

Comments
 (0)