mirror of
https://bitbucket.org/anguist/ntpa
synced 2026-10-05 19:31:58 +00:00
Optimization & bugfixing
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Carsten Sonne Larsen <cs@innolan.dk>
|
||||
//
|
||||
// Copyright (c) 2013 Carsten Sonne Larsen
|
||||
// Copyright (c) 2013-2016 Carsten Sonne Larsen
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -31,6 +31,7 @@ using System.Threading;
|
||||
using Ntp.Analyzer.Config;
|
||||
using Ntp.Analyzer.Export;
|
||||
using Ntp.Config;
|
||||
using Ntp.System;
|
||||
|
||||
namespace Ntp.Analyzer.Validate.Cli
|
||||
{
|
||||
@@ -42,31 +43,53 @@ namespace Ntp.Analyzer.Validate.Cli
|
||||
{
|
||||
// Neutralize.
|
||||
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
|
||||
bool exit = false;
|
||||
bool verbose = false;
|
||||
|
||||
if (args.Length == 0 || args.Length > 2) {
|
||||
ShowUsage ();
|
||||
Ntp.System.OptionSet p =
|
||||
new Ntp.System.OptionSet () { { "h|?|help", v => {
|
||||
ShowUsage ();
|
||||
exit = true;
|
||||
}
|
||||
}, { "v|verbose", v => {
|
||||
verbose = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
String[] rem = p.Parse (args).ToArray ();
|
||||
|
||||
if (exit) {
|
||||
return;
|
||||
} else if (rem.Length > 1) {
|
||||
Console.WriteLine ("Unknown option: " + rem [1]);
|
||||
return;
|
||||
} else if (rem.Length == 0) {
|
||||
Console.WriteLine ("Please specify configuration file");
|
||||
return;
|
||||
}
|
||||
|
||||
Configuration config = null;
|
||||
try {
|
||||
config = LoadConfig (args [0]);
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine ("Unexpected error while loading configuration file: " + e.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length == 1 && args[0] == "help") {
|
||||
ShowUsage ();
|
||||
if (config == null)
|
||||
return;
|
||||
}
|
||||
|
||||
string configFile = args [0];
|
||||
|
||||
Configuration config = LoadConfig (configFile);
|
||||
if (config == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine ("Parsed config ...");
|
||||
|
||||
if (args.Length == 2 && args [1] == "verbose") {
|
||||
if (verbose)
|
||||
Console.WriteLine (config);
|
||||
}
|
||||
|
||||
TestFilesystem (config);
|
||||
try {
|
||||
TestFilesystem (config);
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine ("Unexpected error while testing filesystem: " + e.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!anyErrors) {
|
||||
Console.WriteLine ("Filesystem configuration seems valid ...");
|
||||
@@ -132,8 +155,8 @@ namespace Ntp.Analyzer.Validate.Cli
|
||||
|
||||
private static void ShowUsage()
|
||||
{
|
||||
Console.WriteLine ("NTP Analyzer validator tool.");
|
||||
Console.WriteLine ("Usage: ntpav configuration [verbose]");
|
||||
Console.WriteLine ("NTP Analyzer validator tool " + VersionInfo.Text);
|
||||
Console.WriteLine ("Usage: ntpav [--verbose] configuration");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user