forked from antono/shelr
/
shelr
executable file
·107 lines (89 loc) · 2.39 KB
/
shelr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
require 'rubygems'
require 'shelr'
BASENAME = File.basename(__FILE__)
HELP = <<-HELP
Usage: #{BASENAME} command [arg]
COMMANDS:
Recording:
record - record new shellcast
record --sound - record new shellcast with sound
Publishing:
push last - publish last record
push last --private - publish private record
push RECORD_ID - publish record with given id
Getting record as json:
dump last - dump last record as json to current dir
dump RECORD_ID - dump any record as json to current dir
Replaying:
list - print list of records
play last - play last local record
play RECORD_ID - play local record
play RECORD_URL - play remote record
play dump.json - play local file dumped with `shelr dump`
Setup:
setup API_KEY [API_URL] - set your API key and API site
backend [ttyrec|script] - setup recorder backend
Visit: http://shelr.tv/ for more info.
HELP
case ARGV[0]
when '-h', '--help'
puts HELP
when 'record'
Shelr::Recorder.record!(:sound => ARGV[1] == '--sound')
when 'list'
Shelr::Player.list
when 'play'
if ARGV[1]
if ARGV[1] =~ /^https?:.*/ # remote file
Shelr::Player.play_remote(ARGV[1])
elsif ARGV[1] =~ /.*\.json$/ # local file
Shelr::Player.play_dump(ARGV[1])
else
Shelr::Player.play(:record_id => ARGV[1])
end
else
puts "Missing id for shellcast"
Shelr::Player.list
puts "Select one..."
end
when 'stop'
puts '=> type "exit" or Ctrl+D'
puts '=> Then `shelr push last`'
when 'dump'
if ARGV[1]
Shelr::Publisher.new.dump(ARGV[1])
else
puts "What do you want to dump?"
Shelr::Player.list
puts "Select one..."
end
when 'push'
if ARGV[1]
Shelr::Publisher.new.publish(ARGV[1], ARGV[2] == '--private')
else
puts "What do you want to publish?"
Shelr::Player.list
puts "Select one..."
end
when 'setup'
if ARGV[2]
Shelr.api_url = ARGV[2]
end
if ARGV[1]
Shelr.api_key = ARGV[1]
else
puts "\n\tUsage: #{BASENAME} setup API_KEY\n\n"
end
when 'backend'
if ARGV[1]
Shelr.backend = ARGV[1]
else
puts "\n\tUsage: #{BASENAME} backend [ttyrec|script]\n\n"
end
when 'version'
puts Shelr::VERSION
else
puts HELP
end