1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
using System;
using Mono.CodeContracts.Static;
using Mono.Options;
namespace cccheck {
internal class Program {
private static void Main (string[] args)
{
var options = new CheckOptions ();
bool showOptions = false;
string showMsg = null;
var optionSet = new OptionSet {
{"help", "Show this help.", v => showOptions = v != null},
{"assembly=", "Assembly to check.", v => options.Assembly = v},
{"method=", "Method name (if you want to check only it).", v => options.Method = v},
{"debug=", "Show debug information", v=> options.ShowDebug = v != null}
};
try {
optionSet.Parse (args);
} catch (OptionException e) {
showOptions = true;
showMsg = e.Message;
}
if (showOptions) {
Console.WriteLine ("cccheck");
Console.WriteLine ();
Console.WriteLine ("Options:");
optionSet.WriteOptionDescriptions (Console.Out);
Console.WriteLine ();
if (showMsg != null) {
Console.WriteLine (showMsg);
Console.WriteLine ();
}
return;
}
CheckResults results = Checker.Check (options);
Console.WriteLine ();
if (results.AnyErrors) {
foreach (string error in results.Errors)
Console.WriteLine ("Error: " + error);
}
if (results.AnyWarnings) {
foreach (string warning in results.Warnings)
Console.WriteLine ("Warning: " + warning);
}
if (results.Results != null) {
foreach (var methodValidationResults in results.Results) {
string methodName = methodValidationResults.Key;
Console.WriteLine ("Method: " + methodName);
foreach (string result in methodValidationResults.Value)
Console.WriteLine (" " + result);
Console.WriteLine ();
}
}
Console.WriteLine ();
Console.WriteLine ("*** done ***");
}
}
}
|