This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

* src/MainClass.cs: Add commandline parsing support

svn path=/trunk/tsunami/; revision=114801
  • Loading branch information...
alanmcgovern committed Oct 3, 2008
1 parent 79b6cd2 commit 531418a28d08bb9b5c872a3b885fa33ef8cc8e07
Showing with 26 additions and 0 deletions.
  1. +26 −0 src/MainClass.cs
View
@@ -27,6 +27,7 @@
//
using System;
+using System.IO;
namespace Tsunami
{
@@ -35,7 +36,32 @@ class MainClass
static void Main(string[] args)
{
TrackerHost host = new TrackerHost();
+ ParseArgs(args, host);
host.Run();
}
+
+ static void ParseArgs(string[] args, TrackerHost host)
+ {
+ for (int i = 0; (i +1) < args.Length; i += 2)
+ {
+ switch(args[i])
+ {
+ case ("-d"):
+ if (!System.IO.Directory.Exists (args[i+1]))
+ Console.WriteLine ("Invalid directory: {0}", args[i+1]);
+ else
+ host.AddWatcher(args[i+1]);
+ break;
+
+ case ("-u"):
+ Uri uri;
+ if (!Uri.TryCreate (args[i+1], UriKind.Absolute, out uri))
+ Console.WriteLine ("Invalid url: {0}", args[i+1]);
+ else
+ host.AddListener (uri);
+ break;
+ }
+ }
+ }
}
}

0 comments on commit 531418a

Please sign in to comment.