Skip to content

Commit

Permalink
Added basic support for command line options (port and help).
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlawrence committed Sep 7, 2009
1 parent 5b8072f commit f32944c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
33 changes: 33 additions & 0 deletions Cuke4Nuke/Server/Program.cs
@@ -1,4 +1,5 @@
using System;
using NDesk.Options;

namespace Cuke4Nuke.Server
{
Expand All @@ -7,7 +8,39 @@ class Program
static void Main(string[] args)
{
int port = 3901;
bool showHelp = false;

var p = new OptionSet()
{
{
"p|port=",
"the {PORT} the server should listen on.",
(int v) => port = v
},
{
"h|?|help",
"show this message and exit.",
v => showHelp = v != null
}
};
p.Parse(args);

if (showHelp)
{
ShowHelp(p);
return;
}

Listener listener = new Listener(port);
}

static void ShowHelp(OptionSet p)
{
Console.WriteLine("Usage: Cuke4Nuke.Server.exe [OPTIONS]");
Console.WriteLine("Start the Cuke4Nuke server to invoke .NET Cucumber step definitions.");
Console.WriteLine();
Console.WriteLine("Options:");
p.WriteOptionDescriptions(Console.Out);
}
}
}
4 changes: 2 additions & 2 deletions Cuke4Nuke/Test/Server_Specification.cs
Expand Up @@ -13,15 +13,15 @@ namespace Test
public class Server_Specification
{
Process serverProcess;
int port = 3901;
int port = 3902;
TcpClient client;

[TestFixtureSetUp]
public void TestFixtureSetup()
{
// launch the Cuke4Nuke server in a separate process
string serverExePath = @"..\..\..\Server\bin\Debug\Cuke4Nuke.Server.exe";
serverProcess = Process.Start(serverExePath);
serverProcess = Process.Start(serverExePath, "-p " + port);

// connect to the Cuke4Nuker server over TCP
client = new TcpClient("localhost", port);
Expand Down

0 comments on commit f32944c

Please sign in to comment.