mirror of
https://bitbucket.org/anguist/ntpa
synced 2025-10-06 02:51:23 +00:00
Cleanup
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user