Merge origin/master to prepare the integration
[nit.git] / src / nitdbg_client.nit
old mode 100755 (executable)
new mode 100644 (file)
similarity index 91%
rename from src/dbgcli.nit
rename to src/nitdbg_client.nit
index c80e8c3..4b01ecd
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# Client for the nit debugger nitdbg
+# Client for the nit debugger nitdbg-server
 #
 # Can send commands to the debugger
-module dbgcli
+module nitdbg_client
 
 import socket
 import toolcontext
@@ -65,7 +65,6 @@ class DebugClient
                print "[HOST ADDRESS] : "+debugger_connection.address
                print "[HOST] : "+debugger_connection.host.as(not null)
                print "[PORT] : "+debugger_connection.port.to_s
-               print "Connecting ... "+debugger_connection.connect.to_s
        end
 
        init with_port (host: String, port: Int)
@@ -104,15 +103,12 @@ end
 
 # Create a tool context to handle options and paths
 var toolcontext = new ToolContext
-toolcontext.process_options
+toolcontext.tooldescription = "Usage: nitdbg_client [OPTION]...\nConnects to a nitdbg_server and controls it."
+toolcontext.accept_no_arguments = true
+toolcontext.process_options(args)
 
 var debug: DebugClient
 
-if toolcontext.opt_help.value then
-       toolcontext.option_context.usage
-       return
-end
-
 # If the port value is not an Int between 0 and 65535 (Mandatory according to the norm)
 # Print the usage
 if toolcontext.opt_debug_port.value < 0 or toolcontext.opt_debug_port.value > 65535 then
@@ -133,6 +129,10 @@ else
        debug = new DebugClient("127.0.0.1", toolcontext.opt_debug_port.value)
 end
 
+var res = debug.debugger_connection.connect
+print "Connecting ... " + res.to_s
+if not res then exit 1
+
 var recv_cmd: String
 
 var written_cmd: String