void ParseOptions(string[] args)
{
bool noLogo = false;
ArrayList arglist = new ArrayList(args);
ExpandResponseFiles(ref arglist);
AddDefaultResponseFile(ref arglist);
foreach (string arg in arglist)
{
if ("-" == arg)
{
_options.Input.Add(new StringInput("<stdin>", Consume(Console.In)));
continue;
}
if (!IsFlag(arg))
{
_options.Input.Add(new FileInput(StripQuotes(arg)));
continue;
}
if ("-utf8" == arg) continue;
switch (arg[1])
{
case 'h':
{
if (arg == "-help" || arg == "-h")
{
Help();
}
break;
}
case 'w':
{
if (arg == "-wsa")
{
_options.WhiteSpaceAgnostic = _whiteSpaceAgnostic = true;
}
else
{
InvalidOption(arg);
}
break;
}
case 'v':
{
_options.EnableTraceSwitch();
_options.TraceLevel = TraceLevel.Warning;
Trace.Listeners.Add(new TextWriterTraceListener(Console.Error));
if (arg.Length > 2)
{
switch (arg.Substring(1))
{
case "vv":
{
_options.TraceLevel = TraceLevel.Info;
MonitorAppDomain();
break;
}
case "vvv":
{
_options.TraceLevel = TraceLevel.Verbose;
break;
}
}
}
else
{
_options.TraceLevel = TraceLevel.Warning;
}
break;
}
case 'r':
{
if (arg.IndexOf(":") > 2 && arg.Substring(1, 9) != "reference")
{
switch (arg.Substring(1, 8))
{
case "resource":
{
int start = arg.IndexOf(":") + 1;
AddResource(StripQuotes(arg.Substring(start)));
break;
}
default:
{
InvalidOption(arg);
break;
}
}
}
else
{
string assemblyName = StripQuotes(arg.Substring(arg.IndexOf(":")+1));
_references.Add(assemblyName);
}
break;
}
case 'l':
{
switch (arg.Substring(1, 3))
{
case "lib":
{
string paths = arg.Substring(arg.IndexOf(":")+1);
if (paths == "")
{
Console.Error.WriteLine(Boo.Lang.ResourceManager.Format("BooC.BadLibPath", arg));
break;
}
foreach(string dir in paths.Split(new Char[] {','}))
{
if (Directory.Exists(dir))
{
_options.LibPaths.Add(dir);
}
else
{
Console.Error.WriteLine(Boo.Lang.ResourceManager.Format("BooC.BadLibPath", dir));
}
}
break;
}
default:
{
InvalidOption(arg);
break;
}
}
break;
}
case 'n':
{
if (arg == "-nologo")
{
noLogo = true;
}
else if (arg == "-noconfig")
{
_noConfig = true;
}
else if (arg == "-nostdlib")
{
_options.StdLib = false;
}
else
{
InvalidOption(arg);
}
break;
}
case 'o':
{
_options.OutputAssembly = StripQuotes(arg.Substring(arg.IndexOf(":")+1));
break;
}
case 't':
{
string targetType = arg.Substring(arg.IndexOf(":")+1);
switch (targetType)
{
case "library":
{
_options.OutputType = CompilerOutputType.Library;
break;
}
case "exe":
{
_options.OutputType = CompilerOutputType.ConsoleApplication;
break;
}
case "winexe":
{
_options.OutputType = CompilerOutputType.WindowsApplication;
break;
}
default:
{
InvalidOption(arg);
break;
}
}
break;
}
case 'p':
{
if (arg.StartsWith("-pkg:"))
{
string packages = StripQuotes(arg.Substring(arg.IndexOf(":")+1));
_packages.Add(packages);
}
else {
_pipelineName = StripQuotes(arg.Substring(3));
}
break;
}
case 'c':
{
switch (arg.Substring(1))
{
case "checked":
case "checked+":
{
_options.Checked = true;
break;
}
case "checked-":
{
_options.Checked = false;
break;
}
default:
{
string culture = arg.Substring(3);
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(culture);
break;
}
}
break;
}
case 's':
{
switch (arg.Substring(1, 6))
{
case "srcdir":
{
string path = StripQuotes(arg.Substring(8));
AddFilesForPath(path, _options);
break;
}
default:
{
InvalidOption(arg);
break;
}
}
break;
}
case 'k':
{
if (arg.Substring(1, 7) == "keyfile")
{
_options.KeyFile = StripQuotes(arg.Substring(9));
}
else if (arg.Substring(1, 12) == "keycontainer")
{
_options.KeyContainer = StripQuotes(arg.Substring(14));
}
else
{
InvalidOption(arg);
}
break;
}
case 'd':
{
switch (arg.Substring(1))
{
case "debug":
case "debug+":
{
_options.Debug = true;
break;
}
case "debug-":
{
_options.Debug = false;
break;
}
case "ducky":
{
_options.Ducky = true;
break;
}
case "debug-steps":
{
_debugSteps = true;
break;
}
case "delaysign":
{
_options.DelaySign = true;
break;
}
default:
{
if (arg.StartsWith("-d:") || arg.StartsWith("-define:"))
{
int skip = arg.StartsWith("-d:") ? 3 : 8;
string[] symbols = StripQuotes(arg.Substring(skip)).Split(",".ToCharArray());
foreach (string symbol in symbols)
{
string[] s_v = symbol.Split("=".ToCharArray(), 2);
if (s_v[0].Length < 1) continue;
if (_options.Defines.ContainsKey(s_v[0]))
{
_options.Defines[s_v[0]] = (s_v.Length > 1) ? s_v[1] : null;
Trace.WriteLine("REPLACED DEFINE '"+s_v[0]+"' WITH VALUE '"+((s_v.Length > 1) ? s_v[1] : string.Empty) +"'");
}
else
{
_options.Defines.Add(s_v[0], (s_v.Length > 1) ? s_v[1] : null);
Trace.WriteLine("ADDED DEFINE '"+s_v[0]+"' WITH VALUE '"+((s_v.Length > 1) ? s_v[1] : string.Empty) +"'");
}
}
}
else
{
InvalidOption(arg);
}
break;
}
}
break;
}
case 'e':
{
switch (arg.Substring(1,8))
{
case "embedres":
{
if (!IsMono)
{
throw new ApplicationException("-embedres is only supported on mono. Try -resource.");
}
int start = arg.IndexOf(":") + 1;
EmbedResource(StripQuotes(arg.Substring(start)));
break;
}
default:
{
InvalidOption(arg);
break;
}
}
break;
}
default:
{
if (arg == "--help")
{
Help();
}
else
{
InvalidOption(arg);
}
break;
}
}
}
if (!noLogo)
{
DoLogo();
}
}