}
string responseFilename = Path.GetFullPath (s.Substring (1));
if (responseFiles.ContainsKey (responseFilename))
- throw new CommandLineException ("We already have " + responseFilename + "file.", 0001);
+ ErrorUtilities.ReportError (1, String.Format ("We already have {0} file.", responseFilename));
responseFiles [responseFilename] = responseFilename;
LoadResponseFile (responseFilename);
}
LoadResponseFile (responseFile);
}
foreach (string s in flatArguments) {
- if (s [0] == '/') {
- ParseFlatArgument (s);
- } else
+ if (s [0] != '/' || !ParseFlatArgument (s))
remainingArguments.Add (s);
}
if (remainingArguments.Count == 0) {
if (files.Length > 0)
projectFile = files [0];
else
- throw new CommandLineException ("No .proj file specified and no found in current directory.", 0003);
+ ErrorUtilities.ReportError (3, "No .proj file specified and no found in current directory.");
} else if (remainingArguments.Count == 1) {
projectFile = (string) remainingArguments [0];
} else {
- throw new CommandLineException ("Too many project files specified.", 0004);
+ ErrorUtilities.ReportError (4, "Too many project files specified");
}
}
- private void LoadResponseFile (string filename)
+ void LoadResponseFile (string filename)
{
StreamReader sr = null;
string line;
for (int i = 0; i < t; i++) {
char c = line [i];
+ if (c == '#')
+ // comment, ignore rest of the line
+ break;
+
if (c == '"' || c == '\'') {
char end = c;
sb.Length = 0;
}
}
- } catch (Exception ex) {
- throw new CommandLineException ("Error during loading response file.", ex, 0002);
- } finally {
+ } catch (Exception) {
+ // FIXME: we lose exception message
+ ErrorUtilities.ReportError (2, "Error during loading response file.");
+ } finally {
if (sr != null)
sr.Close ();
}
}
- private void ParseFlatArgument (string s)
+ private bool ParseFlatArgument (string s)
{
switch (s) {
case "/help":
case "/h":
case "/?":
- throw new CommandLineException ("Show usage", 0006);
+ ErrorUtilities.ShowUsage ();
+ break;
case "/nologo":
noLogo = true;
break;
case "/version":
case "/ver":
- throw new CommandLineException ("Show version", 0005);
+ ErrorUtilities.ShowVersion (true);
+ break;
case "/noconsolelogger":
case "/noconlog":
noConsoleLogger = true;
default:
if (s.StartsWith ("/target:") || s.StartsWith ("/t:")) {
ProcessTarget (s);
- }
- if (s.StartsWith ("/property:") || s.StartsWith ("/p:")) {
- ProcessProperty (s);
- }
- if (s.StartsWith ("/logger:") || s.StartsWith ("/l:")) {
+ } else if (s.StartsWith ("/property:") || s.StartsWith ("/p:")) {
+ if (!ProcessProperty (s))
+ return false;
+ } else if (s.StartsWith ("/logger:") || s.StartsWith ("/l:")) {
ProcessLogger (s);
- }
- if (s.StartsWith ("/verbosity:") || s.StartsWith ("/v:")) {
+ } else if (s.StartsWith ("/verbosity:") || s.StartsWith ("/v:")) {
ProcessVerbosity (s);
- }
- if (s.StartsWith ("/consoleloggerparameters:") || s.StartsWith ("/clp:")) {
+ } else if (s.StartsWith ("/consoleloggerparameters:") || s.StartsWith ("/clp:")) {
ProcessConsoleLoggerParameters (s);
- }
- if (s.StartsWith ("/validate:") || s.StartsWith ("/val:")) {
+ } else if (s.StartsWith ("/validate:") || s.StartsWith ("/val:")) {
ProcessValidate (s);
- }
+ } else
+ return false;
break;
}
+
+ return true;
}
internal void ProcessTarget (string s)
targets = temp [1].Split (';');
}
- internal void ProcessProperty (string s)
+ internal bool ProcessProperty (string s)
{
string[] parameter, splittedProperties, property;
parameter = s.Split (':');
+ if (parameter.Length != 2) {
+ ErrorUtilities.ReportError (5, "Property name and value expected as /p:<prop name>=<prop value>");
+ return false;
+ }
+
splittedProperties = parameter [1].Split (';');
foreach (string st in splittedProperties) {
+ if (st.IndexOf ('=') < 0) {
+ ErrorUtilities.ReportError (5,
+ "Invalid syntax. Property name and value expected as " +
+ "<prop name>=[<prop value>]");
+ return false;
+ }
property = st.Split ('=');
- properties.AddNewProperty (property [0], property [1]);
+ properties.SetProperty (property [0], property.Length == 2 ? property [1] : "");
}
+
+ return true;
}
internal void ProcessLogger (string s)
}
}
-#endif
\ No newline at end of file
+#endif