qcmd 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/qcmd +5 -1
- data/lib/qcmd/cli.rb +27 -19
- data/lib/qcmd/network.rb +9 -6
- data/lib/qcmd/version.rb +1 -1
- metadata +3 -3
data/bin/qcmd
CHANGED
@@ -9,6 +9,10 @@ opts = Trollop::options do
|
|
9
9
|
version VERSION_STRING
|
10
10
|
opt :verbose, 'Use verbose mode', :default => false
|
11
11
|
opt :debug, "Show full debug output, don't make changes to workspaces", :default => false
|
12
|
+
opt :machine, "Automatically try to connect to the machine with the given name", :type => :string
|
13
|
+
opt :machine_passcode, "Use the given machine passcode", :type => :integer
|
14
|
+
opt :workspace, "Automatically try to connect to the workspace with the given name", :type => :string
|
15
|
+
opt :workspace_passcode, "Use the given workspace passcode", :type => :integer
|
12
16
|
end
|
13
17
|
|
14
18
|
if opts[:verbose]
|
@@ -26,6 +30,6 @@ Qcmd.ascii_qlab
|
|
26
30
|
Qcmd.print
|
27
31
|
Qcmd.print Qcmd.centered_text(VERSION_STRING)
|
28
32
|
|
29
|
-
Qcmd::Network.browse_and_display
|
33
|
+
Qcmd::Network.browse_and_display opts
|
30
34
|
|
31
35
|
Qcmd::CLI.launch opts
|
data/lib/qcmd/cli.rb
CHANGED
@@ -16,21 +16,21 @@ module Qcmd
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def initialize options={}
|
19
|
+
Qcmd.debug "(launching with options: #{options.inspect})"
|
19
20
|
# start local listening port
|
20
21
|
Qcmd.context = Qcmd::Context.new
|
21
22
|
|
22
23
|
self.prompt = '> '
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
if Qcmd::Network.machines.size == 1 && !Qcmd::Network.machines.first.passcode?
|
30
|
-
puts "AUTOCONNECT"
|
31
|
-
connect Qcmd::Network.machines.first, nil
|
25
|
+
if options[:machine_given]
|
26
|
+
Qcmd.debug "(autoconnecting to #{ options[:machine] })"
|
27
|
+
connect_to_machine_by_name options[:machine], options[:machine_passcode]
|
28
|
+
if options[:workspace_given]
|
29
|
+
connect_to_workspace_by_name options[:workspace], options[:workspace_passcode]
|
32
30
|
end
|
33
31
|
end
|
32
|
+
|
33
|
+
start
|
34
34
|
end
|
35
35
|
|
36
36
|
def connect machine, passcode
|
@@ -56,6 +56,23 @@ module Qcmd
|
|
56
56
|
self.prompt = "#{ machine.name }> "
|
57
57
|
end
|
58
58
|
|
59
|
+
def connect_to_machine_by_name machine_name, passcode
|
60
|
+
if machine = Qcmd::Network.find(machine_name)
|
61
|
+
print "connecting to machine: #{machine_name}"
|
62
|
+
connect machine, passcode
|
63
|
+
else
|
64
|
+
print 'sorry, that machine could not be found'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def connect_to_workspace_by_name workspace_name, passcode
|
69
|
+
if workspace = Qcmd.context.machine.find_workspace(workspace_name)
|
70
|
+
workspace.passcode = passcode
|
71
|
+
print "connecting to workspace: #{workspace_name}"
|
72
|
+
use_workspace workspace
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
59
76
|
def use_workspace workspace
|
60
77
|
Qcmd.debug %[(connecting to workspace: "#{workspace.name}")]
|
61
78
|
# set workspace in context. Will unset later if there's a problem.
|
@@ -99,12 +116,7 @@ module Qcmd
|
|
99
116
|
machine_name = args.shift
|
100
117
|
passcode = args.shift
|
101
118
|
|
102
|
-
|
103
|
-
print "connecting to machine: #{machine_name}"
|
104
|
-
connect machine, passcode
|
105
|
-
else
|
106
|
-
print 'sorry, that machine could not be found'
|
107
|
-
end
|
119
|
+
connect_to_machine_by_name machine_name, passcode
|
108
120
|
when 'disconnect'
|
109
121
|
reset
|
110
122
|
Qcmd::Network.browse_and_display
|
@@ -116,11 +128,7 @@ module Qcmd
|
|
116
128
|
|
117
129
|
Qcmd.debug "(using workspace: #{ workspace_name.inspect })"
|
118
130
|
|
119
|
-
|
120
|
-
workspace.passcode = passcode
|
121
|
-
print "connecting to workspace: #{workspace_name}"
|
122
|
-
use_workspace workspace
|
123
|
-
end
|
131
|
+
connect_to_workspace_by_name workspace_name, passcode
|
124
132
|
when 'cues'
|
125
133
|
if !Qcmd.context.workspace_connected?
|
126
134
|
print "You must be connected to a workspace before you can view a cue list."
|
data/lib/qcmd/network.rb
CHANGED
@@ -27,9 +27,6 @@ module Qcmd
|
|
27
27
|
naps += 1
|
28
28
|
|
29
29
|
if machines.size != previous
|
30
|
-
Qcmd.print
|
31
|
-
Qcmd.print "Found #{ machines.size } QLab machine#{ machines.size == 1 ? '' : 's'}"
|
32
|
-
Qcmd.print
|
33
30
|
previous = machines.size
|
34
31
|
end
|
35
32
|
end
|
@@ -37,9 +34,13 @@ module Qcmd
|
|
37
34
|
Thread.kill(browse_thread) if browse_thread.alive?
|
38
35
|
end
|
39
36
|
|
40
|
-
def display
|
37
|
+
def display options={}
|
41
38
|
longest = machines.map {|m| m.name.size}.max
|
42
39
|
|
40
|
+
Qcmd.print
|
41
|
+
Qcmd.print "Found #{ machines.size } QLab machine#{ machines.size == 1 ? '' : 's'}"
|
42
|
+
Qcmd.print
|
43
|
+
|
43
44
|
machines.each_with_index do |machine, n|
|
44
45
|
if Qcmd.debug?
|
45
46
|
Qcmd.print "#{ n + 1 }. %-#{ longest + 2 }s %s" % [machine.name, machine.client_string]
|
@@ -53,9 +54,11 @@ module Qcmd
|
|
53
54
|
Qcmd.print
|
54
55
|
end
|
55
56
|
|
56
|
-
def browse_and_display
|
57
|
+
def browse_and_display options={}
|
57
58
|
browse
|
58
|
-
|
59
|
+
if options[:machine_given] && !find(options[:machine_name]).nil?
|
60
|
+
display options
|
61
|
+
end
|
59
62
|
end
|
60
63
|
|
61
64
|
def find machine_name
|
data/lib/qcmd/version.rb
CHANGED
metadata
CHANGED