23 using System.Globalization;
31 namespace Ntp.Analyzer.Validate.Cli
35 private const int ParameterErrorCode = 2;
36 private const int ConfigErrorCode = 1;
37 private const int SuccessCode = 0;
40 public static int Main(
string[] args)
42 Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
43 bool validate =
false;
49 {
"h|?|help", v => { ShowUsage(); }},
50 {
"s|show", v => { show =
true; }},
51 {
"d|default", v => { dec.ShowDefaultValues =
true; }},
52 {
"v|validate", v => { validate =
true; }},
53 {
"t=|tabs=", v => SetDecompilerParam(dec,
'\t', v)},
54 {
"w=|whitespace=", v => SetDecompilerParam(dec,
' ', v)}
61 rem = param.Parse(args).ToArray();
65 Console.WriteLine(e.Message);
66 return ParameterErrorCode;
71 return ParameterErrorCode;
76 Console.WriteLine(
"Wrong parameters.");
77 return ParameterErrorCode;
80 if (!show && !validate)
83 return ParameterErrorCode;
89 config = LoadConfig(rem[0]);
93 Console.WriteLine($
"Unexpected error while loading configuration file: {e.Message}");
94 return ConfigErrorCode;
98 return ConfigErrorCode;
102 dec.Configuration = config;
103 Console.Write(dec.Execute());
107 Console.WriteLine(
"Configuration is valid.");
115 if (!File.Exists(configFile))
117 Console.WriteLine($
"Cannot find configuration file {configFile}");
122 var config = reader.Execute();
126 foreach (
string error
in reader.Errors)
128 Console.WriteLine(error);
138 decompiler.
IndentSize =
int.TryParse(count, out parsed) ? parsed : 1;
143 Console.WriteLine(
"NTP Analyzer validator tool v0.8.2");
144 Console.WriteLine(
"Usage: ntpav [-s|-v] [-d] [-t n|-w n] configuration");
145 Console.WriteLine(
" -s Show parsed configuration");
146 Console.WriteLine(
" -v Check if configuration is valid");
147 Console.WriteLine(
" -d Show all default value");
148 Console.WriteLine(
" -t Indent with n tabulators");
149 Console.WriteLine(
" -w Indent with n whitespaces");
char IndentChar
Gets or sets the indent char.
static void SetDecompilerParam(Decompiler decompiler, char indent, string count)
static Configuration LoadConfig(string configFile)
int IndentSize
Gets or sets the size of the indent.
static int Main(string[] args)