require -loginuri on pCampBot

0.6.0-stable
Sean Dague 2008-02-26 21:10:57 +00:00
parent b8e6d6e245
commit 8d31fc2cd0
2 changed files with 22 additions and 16 deletions

View File

@ -117,7 +117,7 @@ namespace pCampBot
firstname = startupConfig.GetString("firstname", "random"); firstname = startupConfig.GetString("firstname", "random");
lastname = startupConfig.GetString("lastname", "random"); lastname = startupConfig.GetString("lastname", "random");
password = startupConfig.GetString("password", "12345"); password = startupConfig.GetString("password", "12345");
loginURI = startupConfig.GetString("loginuri", "http://10.1.1.5:9000"); loginURI = startupConfig.GetString("loginuri");

View File

@ -52,34 +52,40 @@ namespace pCampBot
[STAThread] [STAThread]
public static void Main(string[] args) public static void Main(string[] args)
{ {
//Set up our nifty config.. thanks to nini IConfig config = ParseConfig(args);
ArgvConfigSource cs = new ArgvConfigSource(args); if (config.Get("help") != null || config.Get("loginuri") == null) {
cs.AddSwitch("Startup", "botcount","n");
cs.AddSwitch("Startup", "loginuri","l");
cs.AddSwitch("Startup", "firstname");
cs.AddSwitch("Startup", "lastname");
cs.AddSwitch("Startup", "password");
cs.AddSwitch("Startup", "help","h");
IConfig ol = cs.Configs["Startup"];
if (ol.Get("help") != null) {
Help(); Help();
} else { } else {
int botcount = ol.GetInt("botcount", 1); int botcount = config.GetInt("botcount", 1);
BotManager bm = new BotManager(); BotManager bm = new BotManager();
//startup specified number of bots. 1 is the default //startup specified number of bots. 1 is the default
bm.dobotStartup(botcount, ol); bm.dobotStartup(botcount, config);
while (true) while (true)
{ {
MainConsole.Instance.Prompt(); MainConsole.Instance.Prompt();
} }
} }
} }
private static IConfig ParseConfig(String[] args)
{
//Set up our nifty config.. thanks to nini
ArgvConfigSource cs = new ArgvConfigSource(args);
cs.AddSwitch("Startup", "botcount","n");
cs.AddSwitch("Startup", "loginuri","l");
cs.AddSwitch("Startup", "firstname");
cs.AddSwitch("Startup", "lastname");
cs.AddSwitch("Startup", "password");
cs.AddSwitch("Startup", "help","h");
IConfig ol = cs.Configs["Startup"];
return ol;
}
public static void Help() private static void Help()
{ {
System.Console.WriteLine( System.Console.WriteLine(
"usage: pCampBot <-loginuri loginuri> [OPTIONS]\n" + "usage: pCampBot <-loginuri loginuri> [OPTIONS]\n" +