lib/qcmd/cli.rb in qcmd-0.1.9 vs lib/qcmd/cli.rb in qcmd-0.1.10
- old
+ new
@@ -34,16 +34,13 @@
if options[:command_given]
handle_input Qcmd::Parser.parse(options[:command])
return
end
- elsif Qcmd.context.machine.workspaces.size == 1 &&
- !Qcmd.context.machine.workspaces.first.passcode? &&
- !Qcmd.context.workspace_connected?
- if !connect_default_workspace
- Handler.print_workspace_list
- end
+ elsif !connect_default_workspace
+ Handler.print_workspace_list
+ # end
end
end
# add aliases to input completer
InputCompleter.add_commands aliases.keys
@@ -383,11 +380,11 @@
when 'workspace'
workspace_command = args[1]
if !Qcmd.context.workspace_connected?
- handle_failed_workspace_command cli_input
+ handle_failed_workspace_command args
return
end
if workspace_command.nil?
print_wrapped("no workspace command given. available workspace commands
@@ -400,11 +397,11 @@
when 'help'
Qcmd::Commands::Help.print_all_commands
when 'cues'
if !Qcmd.context.workspace_connected?
- handle_failed_workspace_command cli_input
+ handle_failed_workspace_command args
return
end
# reload cues
load_cues
@@ -423,11 +420,11 @@
when /^(cue|cue_id)$/
# id_field = $1
if !Qcmd.context.workspace_connected?
- handle_failed_workspace_command cli_input
+ handle_failed_workspace_command args
return
end
if args.size < 3
print "Cue commands should be in the form:"
@@ -523,18 +520,21 @@
end
elsif Qcmd.context.cue_connected? && Qcmd::InputCompleter::ReservedCueWords.include?(command)
# prepend the given command with a cue address
if Qcmd.context.cue.number.nil? || Qcmd.context.cue.number.size == 0
- command = "cue_id/#{ Qcmd.context.cue.id }/#{ command }"
+ command_args = [:cue_id, Qcmd.context.cue.id, command]
else
- command = "cue/#{ Qcmd.context.cue.number }/#{ command }"
+ command_args = [:cue, Qcmd.context.cue.number, command]
end
- args = [command].push(*args[1..-1])
+ # add the rest of the given args
+ Qcmd.debug "adding #{args[1..-1].inspect} to #{ command_args.inspect }"
+ command_args.push(*args[1..-1])
- cue_action = Qcmd::CueAction.new(args)
+ Qcmd.debug "creating cue action with #{command_args.inspect}"
+ cue_action = Qcmd::CueAction.new(command_args)
reply = cue_action.evaluate
handle_simple_reply reply
elsif Qcmd.context.workspace_connected? && Qcmd::InputCompleter::ReservedWorkspaceWords.include?(command)
@@ -566,10 +566,11 @@
end
end
end
def handle_failed_workspace_command command
+ command = command.join ' '
print_wrapped(%[The command, "#{ command }" can't be processed yet. you must
first connect to a machine and a workspace
before issuing other commands.])
end
@@ -611,11 +612,11 @@
print data.to_s
end
end
def fixate_on_cue cue_action
- # fixate on cue
+ # fixate on the cue which is the subject of the given action
if Qcmd.context.workspace.has_cues?
_cue = Qcmd.context.workspace.cues.find {|cue|
case cue_action.id_field
when :cue
cue.number.to_s == cue_action.identifier.to_s
@@ -647,11 +648,15 @@
def load_workspaces
Qcmd.context.machine.workspaces = Qcmd::Action.evaluate('workspaces').map {|ws| QLab::Workspace.new(ws)}
end
def connect_default_workspace
- if Qcmd.context.machine.workspaces.size == 1 && !Qcmd.context.machine.workspaces.first.passcode?
+ connectable = Qcmd.context.machine.workspaces.size == 1 &&
+ !Qcmd.context.machine.workspaces.first.passcode? &&
+ !Qcmd.context.workspace_connected?
+ if connectable
connect_to_workspace_by_index(0, nil)
+
true
else
false
end
end