private void ProcessArgs(string[] args)
{
foreach (var arg in args)
{
if (!arg.StartsWith("-"))
{
throw new Exception("Invalid argument: " + arg);
}
string[] argValues = arg.Split(new []{':'}, 2);
string commandName = argValues[0].Remove(0, 1);
string commandValue = argValues.Length == 1 ? null : argValues[1];
switch (commandName.ToLower())
{
case "source":
sourceDirectory = commandValue;
break;
case "target":
targetDirectory = commandValue;
break;
case "version":
version = commandValue;
break;
case "deltas":
int deltas;
if (!int.TryParse(commandValue, out deltas))
{
throw new Exception("The 'delta' argument is not a valid number.");
}
numberOfVersionsAsDelta = deltas;
break;
default:
throw new Exception("Unknown argument: " + arg);
}
}
}