lib/qcmd/cli.rb in qcmd-0.1.6 vs lib/qcmd/cli.rb in qcmd-0.1.7

- old
+ new

@@ -1,11 +1,10 @@ require 'qcmd/server' require 'readline' require 'osc-ruby' -require 'osc-ruby/em_server' module Qcmd class CLI include Qcmd::Plaintext @@ -34,11 +33,11 @@ connect_to_workspace_by_name options[:workspace], options[:workspace_passcode] end if options[:command_given] handle_message options[:command] - puts %[sent command "#{ options[:command] }"] + print %[sent command "#{ options[:command] }"] exit 0 end end end @@ -144,12 +143,27 @@ workspace_name = args.shift passcode = args.shift Qcmd.debug "(using workspace: #{ workspace_name.inspect })" - connect_to_workspace_by_name workspace_name, passcode + if workspace_name + connect_to_workspace_by_name workspace_name, passcode + else + print "No workspace name given. The following workspaces are available:" + Qcmd.context.print_workspace_list + end + when 'help' + help_command = args.shift + + if help_command.nil? + Qcmd::Commands::Help.print_all_commands + # print help according to current context + else + # print command specific help + end + when 'cues' if !Qcmd.context.workspace_connected? failed_workspace_command message return end @@ -177,15 +191,23 @@ if cue_number.nil? print "no cue command given. cue commands should be in the form:" print print " > cue NUMBER COMMAND ARGUMENTS" print - print_wrapped("available cue commands are: #{Qcmd::InputCompleter::ReservedCueWords.join(', ')}") + print_wrapped("available cue commands are: #{Qcmd::Commands::ALL_CUE_COMMANDS.join(', ')}") elsif cue_action.nil? server.send_workspace_command("cue/#{ cue_number }") else server.send_cue_command(cue_number, cue_action, *args) end + + when 'workspaces' + if !Qcmd.context.machine_connected? + print 'cannot load workspaces until you are connected to a machine' + return + end + + server.load_workspaces when 'workspace' workspace_command = args.shift if !Qcmd.context.workspace_connected?