You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class Options
{
[Option('c', "create", Required = false, HelpText = "Creates an empty CSV. Eg: -c \".\\File.csv\"")]
public string EmptyCsvFilePath { get; set; }
[Option('x', "clm", Required = false, HelpText = "Import history from CLM Explorer. Eg: -x \".\\File.csv\"")]
public string ClmExplorerHistoryPath { get; set; }
[Option('h', "hist", Required = false, HelpText = "Import generic history. Eg: -h \".\\File.csv\"")]
public string GenericHistoryPath { get; set; }
}
All these switched are optional. But, if the switch is used then the values must be provided.
How do I handle this? At the moment the paths are null if either the switch is not provided or no path is provided. But it is only an issue if the switch was provided and no path.
public class Options
{
[Option("log", Required = true, HelpText = "Path to log file. Eg: --log \".\\logfile.txt\"")]
public string LogFile { get; set; }
[Option('c', "create", Required = false, HelpText = "Creates an empty CSV. Eg: -c --csv \".\\file.csv\"")]
public bool CreateCsvFile { get; set; }
[Option("csv", Required = false, HelpText = "Specifies CSV filename. Eg: --csv \".\\file.csv\"")]
public string CsvFilePath { get; set; }
[Option("xml", Required = false, HelpText = "Specifies XML filename. Eg: --xml \".\\file.xml\"")]
public string XmlFilePath { get; set; }
[Option('t', "test", Required = false, HelpText = "For testing. Eg: -t --csv \".\\file.csv\" --xml \".\\file.xml\"")]
public bool DoTest { get; set; }
[Option("lang", Required = false, HelpText = "Specifies the language code. Eg: --lang ENG")]
public string LanguageCode { get; set; }
[Option("json", Required = false, HelpText = "Specifies the JSON text. Eg: --json \"json\"")]
public string Json { get; set; }
[Option("mode", Required = false, HelpText = "Specifies the import mode. Eg: --mode clm")]
public string ImportMode { get; set; }
}
I have chosen to include some bool switches. So if the user passes -c or --create for example, then I test to see if the CsvFilePath is valid. Is this the right way to go about it?
For --mode I manually test the value between clm and generic. Can that be factored into the option settings so any other value is flagged?
Activity
ajtruckle commentedon Apr 1, 2024
Update ... these is my current set of switches:
I have chosen to include some
boolswitches. So if the user passes-cor--createfor example, then I test to see if theCsvFilePathis valid. Is this the right way to go about it?For
--modeI manually test the value betweenclmandgeneric. Can that be factored into the option settings so any other value is flagged?