public static void Main(string[] args)
{
#if LOG4NET
// initialize log level
log4net.Repository.ILoggerRepository repo = log4net.LogManager.GetRepository();
repo.Threshold = log4net.Core.Level.Error;
#endif
bool debug = false;
bool listEngines = false;
string engine = "local";
InitLocale();
OptionSet parser = new OptionSet();
parser.Add(
"d|debug",
_("Enable debug output"),
delegate(string value) {
debug = true;
}
);
parser.Add(
"e|engine=",
_("Engine to connect to"),
delegate(string value) {
engine = value;
}
);
parser.Add(
"l|list-engines",
_("List available engines"),
delegate(string value) {
listEngines = true;
}
);
parser.Add(
"h|help",
_("Show this help"),
delegate(string value) {
Console.WriteLine(_("Usage: smuxi-frontend-stfl [options]"));
Console.WriteLine();
Console.WriteLine(_("Options:"));
parser.WriteOptionDescriptions(Console.Out);
Environment.Exit(0);
}
);
parser.Add(
"<>",
delegate(string value) {
throw new OptionException(
String.Format(
_("Unknown option: '{0}'"),
value
),
value
);
}
);
try {
parser.Parse(args);
#if LOG4NET
if (debug)
{
repo.Threshold = log4net.Core.Level.Debug;
}
#endif
} catch (OptionException ex) {
Console.Error.WriteLine(_("Command line error: {0}"), ex.Message);
Environment.Exit(1);
}
if (listEngines)
{
Console.WriteLine(_("Available Engines:"));
var config = new FrontendConfig(Frontend.UIName);
config.Load();
foreach (var entry in (string[])config["Engines/Engines"])
{
Console.WriteLine("\t{0}", entry);
}
return;
}
try {
Frontend.Init(engine);
} catch (Exception e) {
#if LOG4NET
_Logger.Fatal(e);
#endif
if (SysDiag.Debugger.IsAttached)
{
throw;
}
}
}