using System; using CommandLine; using CommandLine.Text; using Deltares.Standard; using Deltares.Standard.Reflection; namespace Deltares.Dam.Tools.CsvToDamxConverter { internal class CommandOptions : CommandLineOptionsBase { [Option("i", "inputDir", Required = true, HelpText = "Input dike data folder to read. (CSV source files)")] public string InputDataDirectory { get; set; } [Option("o", "outputDir", Required = false, DefaultValue = "CsvToDamxOutput", HelpText = "Output folder to save/copy data to. Default value: CsvToDamxOutput")] public string OuputDataDirectory { get; set; } [Option("d", "damxFileName", Required = false, DefaultValue = "input.damx", HelpText = "Name of the DAMX file (without a path). Default value: input.damx")] public string DamXFileName { get; set; } [Option("s", "sensorDataFileName", Required = false, DefaultValue = "sensordata.xls", HelpText = "Name of the sensor data file. Default value: sensordata.xls")] public string SensorDataFileName { get; set; } readonly AssemblyInfoHelper assemblyInfoHelper = new AssemblyInfoHelper(typeof(Program)); private AssemblyInfoHelper ThisAssembly { get { return assemblyInfoHelper; } } [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: CsvToDamXConverter -i DikeCSVInputFolderName [-o OutputFolderName (default=CsvToDamXOutput)] [-d DamXFileName (default=input.damx)] [-s SensorDataFileName (default=sensordata.xls)]"); help.AddOptions(this); return 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); } } } } }