shellplay 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/bin/shellplay +17 -6
- data/bin/shellrecord +73 -18
- data/lib/shellplay/screen.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 491a3d029d1bdb1e7157cd28b55056ff02f93f30
|
4
|
+
data.tar.gz: 1359b3988d567ad789711a0fdacde95238822c03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b7b3cf450b2f7b5f40028ef00e5795eaad3323a39cfd804e4ce4c7f207ee50904ebe3a705c13bf0a6e59029d72c1fcf73de9c6899902e451f98b591d7a3f8b3
|
7
|
+
data.tar.gz: 7d53e72b160c7b00c4fab117bd8e61478e54bb1c5b2d0284256a9001f979ab1c9cf185ef6fa69b867816f8a17df26c2c4d28b755ff4356fce0f42fc06b93575c
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
Shellplay Changelog
|
2
2
|
=========================
|
3
3
|
|
4
|
+
v0.0.5 - 2014-08-12
|
5
|
+
------------------
|
6
|
+
- add a `/` record prefix for clearscreen, works with iterm2 on mac, linux trick don't work yet
|
7
|
+
- add a `?` record prefix for faking output, in case of ssh connection for example
|
8
|
+
- add a `>` to change the prompt and a `>>` to switch prompt back and forth
|
9
|
+
- code is getting messy, it will be time to refactor the record into some classes soon
|
10
|
+
|
4
11
|
v0.0.4 - 2014-08-12
|
5
12
|
------------------
|
6
13
|
- add changelog link in the gemspec
|
data/bin/shellplay
CHANGED
@@ -32,8 +32,19 @@ def usage
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def display(screen)
|
35
|
+
if screen.clearscreen
|
36
|
+
if ENV['TERM_PROGRAM'] = 'iTerm.app'
|
37
|
+
printf "\e]50;ClearScrollback\a"
|
38
|
+
else
|
39
|
+
printf "\e\143"
|
40
|
+
end
|
41
|
+
end
|
35
42
|
if screen.displaycommand
|
36
|
-
|
43
|
+
if screen.customprompt
|
44
|
+
print screen.customprompt
|
45
|
+
else
|
46
|
+
print @session.config.prompt
|
47
|
+
end
|
37
48
|
sleep @sleeptime
|
38
49
|
print screen.stdin
|
39
50
|
STDIN.gets
|
@@ -41,7 +52,7 @@ def display(screen)
|
|
41
52
|
else
|
42
53
|
@lastelapsed = 0
|
43
54
|
end
|
44
|
-
|
55
|
+
print screen.stdout
|
45
56
|
if screen.stderr != ""
|
46
57
|
printf "\n#{Paint[screen.stderr, :red]}"
|
47
58
|
end
|
@@ -68,8 +79,8 @@ def show(index)
|
|
68
79
|
end
|
69
80
|
|
70
81
|
while continue do
|
71
|
-
|
72
|
-
|
82
|
+
print "\n\e[36m>\e[0m " if @playprompt
|
83
|
+
print "\e[35melapsed: #{@lastelapsed}s\e[0m " unless @lastelapsed == 0
|
73
84
|
command = STDIN.gets.strip
|
74
85
|
case command
|
75
86
|
when /^(?:q|x)$/
|
@@ -88,11 +99,11 @@ while continue do
|
|
88
99
|
else
|
89
100
|
Open3.popen3("bash","-l","-c",command.strip) do |i, o, e, t|
|
90
101
|
o.read.split("\n").each do |line|
|
91
|
-
|
102
|
+
print line
|
92
103
|
sleep sleeptime
|
93
104
|
end
|
94
105
|
e.read.split("\n").each do |line|
|
95
|
-
|
106
|
+
print Paint[line, :red]
|
96
107
|
end
|
97
108
|
end
|
98
109
|
end
|
data/bin/shellrecord
CHANGED
@@ -9,14 +9,18 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
9
9
|
require 'shellplay'
|
10
10
|
|
11
11
|
continue = true
|
12
|
-
sleeptime = 1.0/48.0
|
13
12
|
|
14
13
|
session = Shellplay::Session.new
|
15
14
|
prompt = "\e[36mrecord >\e[0m"
|
15
|
+
customprompt = nil
|
16
16
|
|
17
17
|
while continue do
|
18
18
|
printf("\e[36mrecord >\e[33m %d > \e[0m", session.pointer)
|
19
19
|
command = STDIN.gets.strip
|
20
|
+
displaycommand = true
|
21
|
+
playprompt = true
|
22
|
+
clearscreen = false
|
23
|
+
fakeit = false
|
20
24
|
case command
|
21
25
|
when "q"
|
22
26
|
session.save
|
@@ -28,9 +32,31 @@ while continue do
|
|
28
32
|
else
|
29
33
|
session.drop_last_screen
|
30
34
|
end
|
35
|
+
when ""
|
36
|
+
screen = Shellplay::Screen.new
|
37
|
+
session.add_screen({
|
38
|
+
'displaycommand' => false,
|
39
|
+
'playprompt' => false,
|
40
|
+
'clearscreen' => true,
|
41
|
+
'customprompt' => nil,
|
42
|
+
'stdin' => '',
|
43
|
+
'stdout' => '',
|
44
|
+
'stderr' => '',
|
45
|
+
'timespent' => 0
|
46
|
+
})
|
47
|
+
when /^>/
|
48
|
+
command = command[1..-1].strip
|
49
|
+
if command[0] == '>'
|
50
|
+
customprompt = nil
|
51
|
+
else
|
52
|
+
print "New prompt: " + command.gsub(/\\e/,27.chr) + "\n"
|
53
|
+
customprompt = command.gsub(/\\e/,27.chr)
|
54
|
+
end
|
31
55
|
else
|
32
|
-
|
33
|
-
|
56
|
+
if command[0] == '?'
|
57
|
+
command = command[1..-1].strip
|
58
|
+
fakeit = true
|
59
|
+
end
|
34
60
|
if command[0] == '#'
|
35
61
|
command = command[1..-1].strip
|
36
62
|
displaycommand = false
|
@@ -39,27 +65,56 @@ while continue do
|
|
39
65
|
playprompt = false
|
40
66
|
end
|
41
67
|
end
|
42
|
-
|
43
|
-
|
68
|
+
if command[0] == '/'
|
69
|
+
command = command[1..-1].strip
|
70
|
+
clearscreen = true
|
71
|
+
end
|
72
|
+
if fakeit
|
73
|
+
go_on = true
|
74
|
+
out = ""
|
75
|
+
while go_on do
|
76
|
+
line = STDIN.gets
|
77
|
+
if line == ".\n"
|
78
|
+
go_on = false
|
79
|
+
else
|
80
|
+
out << line
|
81
|
+
end
|
82
|
+
end
|
44
83
|
screen = Shellplay::Screen.new
|
45
|
-
out = o.read
|
46
|
-
err = e.read
|
47
|
-
end_time = Time.now
|
48
|
-
elapsed = end_time - start_time
|
49
84
|
session.add_screen({
|
50
85
|
'displaycommand' => displaycommand,
|
51
86
|
'playprompt' => playprompt,
|
87
|
+
'clearscreen' => clearscreen,
|
88
|
+
'customprompt' => customprompt,
|
52
89
|
'stdin' => command,
|
53
90
|
'stdout' => out,
|
54
|
-
'stderr' =>
|
55
|
-
'timespent' =>
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
91
|
+
'stderr' => '',
|
92
|
+
'timespent' => 0
|
93
|
+
})
|
94
|
+
else
|
95
|
+
start_time = Time.now
|
96
|
+
Open3.popen3(command) do |i, o, e, t|
|
97
|
+
screen = Shellplay::Screen.new
|
98
|
+
out = o.read
|
99
|
+
err = e.read
|
100
|
+
end_time = Time.now
|
101
|
+
elapsed = end_time - start_time
|
102
|
+
session.add_screen({
|
103
|
+
'displaycommand' => displaycommand,
|
104
|
+
'playprompt' => playprompt,
|
105
|
+
'clearscreen' => clearscreen,
|
106
|
+
'customprompt' => customprompt,
|
107
|
+
'stdin' => command,
|
108
|
+
'stdout' => out,
|
109
|
+
'stderr' => err,
|
110
|
+
'timespent' => elapsed
|
111
|
+
})
|
112
|
+
out.split("\n").each do |line|
|
113
|
+
puts line
|
114
|
+
end
|
115
|
+
err.split("\n").each do |line|
|
116
|
+
puts Paint[line, :red]
|
117
|
+
end
|
63
118
|
end
|
64
119
|
end
|
65
120
|
session.next
|
data/lib/shellplay/screen.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
module Shellplay
|
2
2
|
class Screen
|
3
3
|
|
4
|
-
attr_reader :stdin, :stdout, :stderr, :display, :timespent, :displaycommand, :playprompt
|
4
|
+
attr_reader :stdin, :stdout, :stderr, :display, :timespent, :displaycommand, :playprompt, :clearscreen, :customprompt
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@displaycommand = true
|
8
8
|
@playprompt = true
|
9
|
+
@clearscreen = false
|
10
|
+
@customprompt = nil
|
9
11
|
@stdin = nil
|
10
12
|
@stdout = nil
|
11
13
|
@stderr = nil
|
@@ -15,6 +17,8 @@ module Shellplay
|
|
15
17
|
def import(hash)
|
16
18
|
@displaycommand = !!hash['displaycommand']
|
17
19
|
@playprompt = !!hash['playprompt']
|
20
|
+
@clearscreen = !!hash['clearscreen']
|
21
|
+
@customprompt = hash['customprompt']
|
18
22
|
@stdin = hash['stdin']
|
19
23
|
@stdout = hash['stdout']
|
20
24
|
@stderr = hash['stderr']
|
@@ -25,6 +29,8 @@ module Shellplay
|
|
25
29
|
{
|
26
30
|
displaycommand: @displaycommand,
|
27
31
|
playprompt: @playprompt,
|
32
|
+
clearscreen: @clearscreen,
|
33
|
+
customprompt: @customprompt,
|
28
34
|
stdin: @stdin,
|
29
35
|
stdout: @stdout,
|
30
36
|
stderr: @stderr,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shellplay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mose
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paint
|