1
0
mirror of https://bitbucket.org/anguist/ntpa synced 2025-10-06 02:51:23 +00:00
This commit is contained in:
2016-08-13 21:42:25 +02:00
parent 051ec409c6
commit 4e9d8a5c44
168 changed files with 2878 additions and 1556 deletions

View File

@ -25,9 +25,9 @@ using System.IO;
using System.Threading;
using Ntp.Analyzer.Common;
using Ntp.Analyzer.Config;
using Ntp.Analyzer.Config.Compiler;
using Ntp.Analyzer.Config.Node;
using Ntp.Interop;
using Ntp.Analyzer.Config.Compiler;
namespace Ntp.Analyzer.Validate.Cli
{
@ -42,12 +42,12 @@ namespace Ntp.Analyzer.Validate.Cli
bool validate = false;
int count;
const int ParameterError = 2;
const int ConfigError = 1;
const int Success = 0;
const int parameterError = 2;
const int configError = 1;
const int success = 0;
Decompiler decompiler = new Decompiler();
Decompiler decompiler = new Decompiler ();
var p =
new OptionSet
{
@ -68,27 +68,17 @@ namespace Ntp.Analyzer.Validate.Cli
"v|validate", v => { validate = true; }
},
{
"t=|tabs=", v => {
"t=|tabs=", v =>
{
decompiler.IndentChar = '\t';
if (int.TryParse(v, out count))
{
decompiler.IndentSize = count;
} else
{
decompiler.IndentSize = 1;
}
decompiler.IndentSize = int.TryParse(v, out count) ? count : 1;
}
},
{
"w=|whitespace=", v => {
"w=|whitespace=", v =>
{
decompiler.IndentChar = ' ';
if (int.TryParse(v, out count))
{
decompiler.IndentSize = count;
} else
{
decompiler.IndentSize = 1;
}
decompiler.IndentSize = int.TryParse(v, out count) ? count : 1;
}
}
};
@ -102,30 +92,30 @@ namespace Ntp.Analyzer.Validate.Cli
catch (Exception e)
{
Console.WriteLine(e.Message);
return ParameterError;
return parameterError;
}
if (exit)
{
return ParameterError;
return parameterError;
}
if (rem.Length > 1)
{
Console.WriteLine("Wrong parameters.");
return ParameterError;
return parameterError;
}
if (rem.Length == 0)
{
Console.WriteLine("Wrong parameters.");
return ParameterError;
return parameterError;
}
if (!show && !validate)
{
ShowUsage();
return ParameterError;
return parameterError;
}
Configuration config;
@ -136,23 +126,24 @@ namespace Ntp.Analyzer.Validate.Cli
catch (Exception e)
{
Console.WriteLine("Unexpected error while loading configuration file: " + e.Message);
return ConfigError;
return configError;
}
if (config == null)
return ConfigError;
return configError;
if (show)
{
decompiler.Configuration = config;
Console.Write(decompiler.Execute ());
Console.Write(decompiler.Execute());
}
else if (validate)
{
// TODO
Console.WriteLine("Configuration is valid.");
}
return Success;
return success;
}
private static Configuration LoadConfig(string configFile)