Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/spielbash/interactor/record_interactor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def create_actions(context, scenes)
when scene.has_key?('delete_env') then
cmd = scene['delete_env']
Spielbash::DeleteEnvironmentAction.new(cmd, context)
when scene.has_key?('tmux_command') then
cmd = scene['tmux_command']
Spielbash::TmuxCommandAction.new(cmd, action_context)
else
not_implemented
end
Expand Down
16 changes: 16 additions & 0 deletions lib/spielbash/model/action/tmux_command_action.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Spielbash
class TmuxCommandAction < Spielbash::BaseAction
attr_accessor :command

def initialize(command, action_context)
super(action_context)
@command = command
end

def execute(session)
session.execute_tmux_with(command, action_context.wait)

sleep(action_context.reading_delay_s)
end
end
end
14 changes: 9 additions & 5 deletions lib/spielbash/model/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ def wait
end

def send_key(key, count=1)
key = 'Space' if key == ' '
key = case key
when ' ' then 'Space'
when ';' then '\\;'
else key
end
execute_tmux_with("send-keys -t #{name} -N #{count} #{key}", true)
end

Expand All @@ -54,6 +58,10 @@ def start_recording
execute_with_exactly('asciinema', false, true, false, "rec", "-y", "-c", "tmux attach -t #{name}", "#{output_path}")
end

def execute_tmux_with(arguments, wait = false)
execute_with('tmux', arguments, wait)
end

private

def exec_wait_check_cmd(pid)
Expand All @@ -65,10 +73,6 @@ def exec_wait_check_cmd(pid)
end
end

def execute_tmux_with(arguments, wait = false)
execute_with('tmux', arguments, wait)
end

def execute_with(cmd, arguments, wait = false, leader = true, io_inherit = false)
args = arguments.split
execute_with_exactly cmd, wait, io_inherit, leader, *args
Expand Down
1 change: 1 addition & 0 deletions lib/spielbash/spielbash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
require 'spielbash/model/action/message_context'
require 'spielbash/model/action/new_environment_action'
require 'spielbash/model/action/delete_environment_action'
require 'spielbash/model/action/tmux_command_action'