showterm 0.2.7 → 0.3.0
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.
- data/bin/showterm +115 -66
- data/lib/showterm.rb +1 -0
- data/showterm.gemspec +1 -1
- metadata +19 -37
data/bin/showterm
CHANGED
|
@@ -3,81 +3,130 @@
|
|
|
3
3
|
require 'readline'
|
|
4
4
|
require File.join(File.dirname(File.dirname(__FILE__)), 'lib/showterm')
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
$edit_timings = true
|
|
8
|
-
ARGV.shift
|
|
9
|
-
end
|
|
6
|
+
class Showterm::Main
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Usage: showterm [-e] <command to run>
|
|
8
|
+
def run
|
|
9
|
+
if ARGV.include?('-h') || ARGV.include?('--help')
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
internet where it can be replayed by anyone to whom you give the URL.
|
|
11
|
+
help
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
elsif ARGV[0] == '--retry'
|
|
14
|
+
|
|
15
|
+
ARGV.shift
|
|
16
|
+
reupload
|
|
17
|
+
|
|
18
|
+
else
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
if '-e' == ARGV[0] || '--edit' == ARGV[0]
|
|
21
|
+
@edit_timings = true
|
|
22
|
+
ARGV.shift
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
sf, tf = record
|
|
26
|
+
sf, tf = edit(sf, tf) if @edit_timings
|
|
27
|
+
upload sf, tf
|
|
28
|
+
end
|
|
29
29
|
end
|
|
30
|
-
path
|
|
31
|
-
end
|
|
32
30
|
|
|
33
|
-
def
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
def record
|
|
32
|
+
puts 'showterm recording. (Exit shell when done.)'
|
|
33
|
+
sf, tf = Showterm.record!(*ARGV)
|
|
34
|
+
puts 'showterm recording finished.'
|
|
35
|
+
[sf, tf]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def help
|
|
39
|
+
puts <<-EOF
|
|
40
|
+
Usage: showterm [-e] <command to run>
|
|
41
|
+
|
|
42
|
+
showterm will record the exact output of your session, and upload it to the
|
|
43
|
+
internet where it can be replayed by anyone to whom you give the URL.
|
|
44
|
+
|
|
45
|
+
You can pass `-e` as the first arg and it will allow you to edit the timings
|
|
46
|
+
file before uploading. This can be nice if you want to take long pauses (such
|
|
47
|
+
as searching an answer out) in between commands.
|
|
48
|
+
EOF
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def reupload
|
|
52
|
+
if ARGV.size == 2
|
|
53
|
+
upload(*ARGV.map{ |path| File.read(path) })
|
|
54
|
+
else
|
|
55
|
+
puts "Usage: showterm --retry <scriptfile> <timesfile>"
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def upload(sf, tf)
|
|
60
|
+
puts "Uploading..."
|
|
61
|
+
puts Showterm.upload! sf, tf
|
|
62
|
+
rescue => e
|
|
63
|
+
puts [e] + e.backtrace
|
|
64
|
+
puts "-" * 80
|
|
65
|
+
die_politely "DON'T PANIC", sf, tf
|
|
66
|
+
end
|
|
41
67
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
def edit(sf, tf)
|
|
69
|
+
prepare_to_edit
|
|
70
|
+
|
|
71
|
+
times_path = save 'times', tf
|
|
72
|
+
success = system(editor, times_path)
|
|
73
|
+
if success
|
|
74
|
+
tf = File.read(times_path)
|
|
75
|
+
else
|
|
76
|
+
die_politely "OK, discarding edits and skipping upload.", sf, tf
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
[sf, tf]
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def prepare_to_edit
|
|
83
|
+
puts "Recording done, now it's time to dress up those timings!" +
|
|
84
|
+
if 'vim' == editor
|
|
85
|
+
<<-TIPS
|
|
86
|
+
Hot vim tips:
|
|
87
|
+
|
|
88
|
+
Use :cq from vim to exit nonzero, and cancel the upload
|
|
89
|
+
Use :%s/^[0-9]\./0./ to get rid of all longish pauses.
|
|
90
|
+
TIPS
|
|
91
|
+
else
|
|
92
|
+
"If you can make your editor return nonzero, it will cancel the upload."
|
|
93
|
+
end +
|
|
94
|
+
"[Hit Enter to edit]"
|
|
95
|
+
|
|
96
|
+
$stdin.readline
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def save(which, data)
|
|
100
|
+
path = "/tmp/showtime.#$$.#{which}"
|
|
101
|
+
File.open(path, 'w') do |f|
|
|
102
|
+
f.write(data)
|
|
103
|
+
end
|
|
104
|
+
path
|
|
58
105
|
end
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
tf = File.read(times_path)
|
|
70
|
-
else
|
|
71
|
-
leave_trace "OK, discarding edits and skipping upload.", sf, tf
|
|
106
|
+
|
|
107
|
+
def die_politely(message, sf, tf)
|
|
108
|
+
script_path = save 'script', sf
|
|
109
|
+
times_path = save 'times', tf
|
|
110
|
+
puts <<-MESSAGE
|
|
111
|
+
#{message}
|
|
112
|
+
your work is safe in "#{script_path}" and "#{times_path}"
|
|
113
|
+
To try uploading manually, use:
|
|
114
|
+
showterm --retry "#{script_path}" "#{times_path}"
|
|
115
|
+
MESSAGE
|
|
72
116
|
exit 1
|
|
73
117
|
end
|
|
74
|
-
end
|
|
75
118
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
puts
|
|
81
|
-
|
|
82
|
-
|
|
119
|
+
def dedent(str)
|
|
120
|
+
str.split("\n").map(&:lstrip).join("\n")
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def puts(str, *a)
|
|
124
|
+
super(String === str ? dedent(str) : str, *a)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def editor
|
|
128
|
+
ENV.fetch('VISUAL', ENV.fetch('EDITOR', 'vim'))
|
|
129
|
+
end
|
|
83
130
|
end
|
|
131
|
+
|
|
132
|
+
Showterm::Main.new.run
|
data/lib/showterm.rb
CHANGED
|
@@ -35,6 +35,7 @@ module Showterm
|
|
|
35
35
|
# @param [String] timingfile The timings
|
|
36
36
|
# @param [Integer] cols The width of the terminal
|
|
37
37
|
def upload!(scriptfile, timingfile, cols=terminal_width)
|
|
38
|
+
retried ||= false
|
|
38
39
|
request = Net::HTTP::Post.new("/scripts")
|
|
39
40
|
request.set_form_data(:scriptfile => scriptfile,
|
|
40
41
|
:timingfile => timingfile,
|
data/showterm.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: showterm
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
hash: 25
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
5
4
|
prerelease:
|
|
6
|
-
|
|
7
|
-
- 0
|
|
8
|
-
- 2
|
|
9
|
-
- 7
|
|
10
|
-
version: 0.2.7
|
|
5
|
+
version: 0.3.0
|
|
11
6
|
platform: ruby
|
|
12
|
-
authors:
|
|
7
|
+
authors:
|
|
13
8
|
- Conrad Irwin
|
|
14
9
|
autorequire:
|
|
15
10
|
bindir: bin
|
|
16
11
|
cert_chain: []
|
|
17
|
-
|
|
18
|
-
date: 2012-11-06 00:00:00 Z
|
|
12
|
+
date: 2012-12-26 00:00:00.000000000 Z
|
|
19
13
|
dependencies: []
|
|
20
|
-
|
|
21
14
|
description: Integrates with showterm.io for awesome sharability.
|
|
22
15
|
email: conrad.irwin@gmail.com
|
|
23
|
-
executables:
|
|
16
|
+
executables:
|
|
24
17
|
- showterm
|
|
25
|
-
extensions:
|
|
18
|
+
extensions:
|
|
26
19
|
- ext/extconf.rb
|
|
27
20
|
extra_rdoc_files: []
|
|
28
|
-
|
|
29
|
-
files:
|
|
21
|
+
files:
|
|
30
22
|
- LICENSE.MIT
|
|
31
23
|
- README.md
|
|
32
24
|
- bin/showterm
|
|
@@ -46,37 +38,27 @@ files:
|
|
|
46
38
|
- showterm.gemspec
|
|
47
39
|
homepage: http://github.com/Conradirwin/showterm
|
|
48
40
|
licenses: []
|
|
49
|
-
|
|
50
41
|
post_install_message:
|
|
51
42
|
rdoc_options: []
|
|
52
|
-
|
|
53
|
-
require_paths:
|
|
43
|
+
require_paths:
|
|
54
44
|
- lib
|
|
55
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
46
|
none: false
|
|
57
|
-
requirements:
|
|
58
|
-
- -
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
- 0
|
|
63
|
-
version: "0"
|
|
64
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
- - ! '>='
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: '0'
|
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
52
|
none: false
|
|
66
|
-
requirements:
|
|
67
|
-
- -
|
|
68
|
-
- !ruby/object:Gem::Version
|
|
69
|
-
|
|
70
|
-
segments:
|
|
71
|
-
- 0
|
|
72
|
-
version: "0"
|
|
53
|
+
requirements:
|
|
54
|
+
- - ! '>='
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '0'
|
|
73
57
|
requirements: []
|
|
74
|
-
|
|
75
58
|
rubyforge_project:
|
|
76
59
|
rubygems_version: 1.8.24
|
|
77
60
|
signing_key:
|
|
78
61
|
specification_version: 3
|
|
79
62
|
summary: Allows you to make screen casts of your terminal really easily
|
|
80
63
|
test_files: []
|
|
81
|
-
|
|
82
64
|
has_rdoc:
|