using System;
using CommandLine;
using CommandLine.Text;
using Deltares.Standard;
using Deltares.Standard.Reflection;
namespace Deltares.Dam.KernelComparisonRunner
{
internal class CommandOptions : CommandLineOptionsBase
{
public const string DefaultKernelSpecificationFileName = "";
public const string DefaultLocationsFileName = "";
public const string DefaultOutputPath = @"Report\";
[Option("d", "DamxFile", Required = true, HelpText = "Name and path of the input DAMX file")]
public string DamXFileName { get; set; }
[Option("k", "KernelSpecificationFileName", Required = false, DefaultValue = DefaultKernelSpecificationFileName,
HelpText = "Name and path of the file with the kernels to calculate (DamClassic, DamClassicDotNet, DamClassicWti, AdvancedDotNet, AdvancedWti)")]
public string KernelSpecificationFileName { get; set; }
[Option("l", "LocationsFileName", Required = false, DefaultValue = DefaultLocationsFileName, HelpText = "Name and path of file with the locations to calculate")]
public string LocationsFileName { get; set; }
[Option("o", "OutputPath", Required = false, DefaultValue = DefaultOutputPath, HelpText = "Path where to output the reports")]
public string OutputPath { get; set; }
readonly AssemblyInfoHelper assemblyInfoHelper = new AssemblyInfoHelper(typeof(Program));
///
/// Gets the assemblyInfoHelper.
///
///
/// The this assembly.
///
private AssemblyInfoHelper ThisAssembly
{
get
{
return assemblyInfoHelper;
}
}
///
/// Gets the help info.
///
///
[HelpOption]
public string GetUsage()
{
var help = new HelpText
{
Heading = new HeadingInfo(ThisAssembly.Title, ThisAssembly.AssemblyVersion),
Copyright = new CopyrightInfo(ThisAssembly.Company, 2012),
AdditionalNewLineAfterOption = true,
AddDashesToOption = true
};
this.HandleParsingErrorsInHelp(help);
//help.AddPreOptionsLine("<>");
help.AddPreOptionsLine("Usage: KernelComparisonRunner[.exe] -d DamxFile [-k KernelSpecificationFileName] [-l LocationsFileName] [-o OutputPath] ");
help.AddOptions(this);
return help;
}
///
/// Handles the parsing errors in help.
///
/// The help.
void HandleParsingErrorsInHelp(HelpText help)
{
if (this.LastPostParsingState.Errors.Count > 0)
{
var errors = help.RenderParsingErrorsText(this, 2); // indent with two spaces
if (!string.IsNullOrEmpty(errors))
{
help.AddPreOptionsLine(string.Concat(Environment.NewLine, "ERROR(S):"));
help.AddPreOptionsLine(errors);
}
}
}
}
}