* small TestClient command line parse fix courtesy of jedediah smith

* added FriendManager.cs to Xcode project file


git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1215 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
jef
2007-06-04 23:40:57 +00:00
parent 037156b1f1
commit 4f37646776
2 changed files with 100 additions and 82 deletions

View File

@@ -5,6 +5,10 @@ using CommandLine.Utility;
namespace libsecondlife.TestClient
{
public class CommandLineArgumentsException : Exception
{
}
public class Program
{
private static void Usage()
@@ -26,102 +30,112 @@ namespace libsecondlife.TestClient
string file = String.Empty;
string contact = String.Empty;
if (arguments["masterkey"] != null)
try
{
masterKey = LLUUID.Parse(arguments["masterkey"]);
}
if (arguments["master"] != null)
{
masterName = arguments["master"];
}
if (arguments["masterkey"] != null)
{
masterKey = LLUUID.Parse(arguments["masterkey"]);
}
if (arguments["contact"] != null)
{
contact = arguments["contact"];
if (arguments["file"] != null)
{
file = arguments["file"];
if (arguments["master"] != null)
{
masterName = arguments["master"];
}
// Loading names from a file
try
{
using (StreamReader reader = new StreamReader(file))
{
string line;
int lineNumber = 0;
if (arguments["contact"] == null)
throw new CommandLineArgumentsException();
while ((line = reader.ReadLine()) != null)
{
lineNumber++;
string[] tokens = line.Trim().Split(new char[] { ' ', ',' });
contact = arguments["contact"];
if (tokens.Length >= 3)
{
account = new LoginDetails();
account.FirstName = tokens[0];
account.LastName = tokens[1];
account.Password = tokens[2];
if (arguments["file"] != null)
{
file = arguments["file"];
accounts.Add(account);
// Loading names from a file
try
{
using (StreamReader reader = new StreamReader(file))
{
string line;
int lineNumber = 0;
// Leaving this out until we have per-account masters (if that
// is desirable). For now the command-line option can
// specify the single master that TestClient supports
//if (tokens.Length == 5)
//{
// master = tokens[3] + " " + tokens[4];
//}
}
else
{
Console.WriteLine("Invalid data on line " + lineNumber +
", must be in the format of: FirstName LastName Password");
}
}
}
}
catch (Exception e)
{
Console.WriteLine("Error reading from " + args[1]);
Console.WriteLine(e.ToString());
return;
}
}
else
{
if (arguments["first"] != null && arguments["last"] != null && arguments["pass"] != null)
{
// Taking a single login off the command-line
account = new LoginDetails();
account.FirstName = arguments["first"];
account.LastName = arguments["last"];
account.Password = arguments["pass"];
while ((line = reader.ReadLine()) != null)
{
lineNumber++;
string[] tokens = line.Trim().Split(new char[] { ' ', ',' });
accounts.Add(account);
}
}
}
if (tokens.Length >= 3)
{
account = new LoginDetails();
account.FirstName = tokens[0];
account.LastName = tokens[1];
account.Password = tokens[2];
accounts.Add(account);
// Leaving this out until we have per-account masters (if that
// is desirable). For now the command-line option can
// specify the single master that TestClient supports
//if (tokens.Length == 5)
//{
// master = tokens[3] + " " + tokens[4];
//}
}
else
{
Console.WriteLine("Invalid data on line " + lineNumber +
", must be in the format of: FirstName LastName Password");
}
}
}
}
catch (Exception e)
{
Console.WriteLine("Error reading from " + args[1]);
Console.WriteLine(e.ToString());
return;
}
}
else if (arguments["first"] != null && arguments["last"] != null && arguments["pass"] != null)
{
// Taking a single login off the command-line
account = new LoginDetails();
account.FirstName = arguments["first"];
account.LastName = arguments["last"];
account.Password = arguments["pass"];
accounts.Add(account);
}
else
{
Usage();
return;
throw new CommandLineArgumentsException();
}
}
foreach (LoginDetails a in accounts)
{
a.MasterName = masterName;
a.MasterKey = masterKey;
}
catch (CommandLineArgumentsException)
{
Usage();
return;
}
foreach (LoginDetails a in accounts)
{
a.MasterName = masterName;
a.MasterKey = masterKey;
}
// Login the accounts and run the input loop
if ( arguments["startpos"] != null ) {
manager = new ClientManager(accounts, contact, arguments["startpos"]);
} else {
manager = new ClientManager(accounts, contact);
}
manager.Run();
if (arguments["startpos"] != null)
{
manager = new ClientManager(accounts, contact, arguments["startpos"]);
}
else
{
manager = new ClientManager(accounts, contact);
}
manager.Run();
}
}
}