-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.cs
More file actions
50 lines (40 loc) · 1.81 KB
/
Options.cs
File metadata and controls
50 lines (40 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System.Collections.Generic;
using CommandLine;
using CommandLine.Text;
namespace optometer
{
public class Options
{
[Option('p', "port", DefaultValue = "COM9", HelpText = "Serial port name.")]
public string Port { get; set; }
[Option('n', "number", DefaultValue = 10, HelpText = "Number of samples.")]
public int MaximumSamples { get; set; }
[Option("comment", DefaultValue = "---", HelpText = "User supplied comment string.")]
public string UserComment { get; set; }
[Option("logfile", DefaultValue = "optometer.log", HelpText = "Log file name.")]
public string LogFileName { get; set; }
[ValueList(typeof(List<string>), MaximumElements = 2)]
public IList<string> ListOfFileNames { get; set; }
[HelpOption]
public string GetUsage()
{
string AppName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
string AppVer = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
HelpText help = new HelpText
{
Heading = new HeadingInfo($"{AppName}, version {AppVer}"),
Copyright = new CopyrightInfo("Michael Matus", 2021),
AdditionalNewLineAfterOption = false,
AddDashesToOption = true
};
string preamble = "Program to operate the photo-current meter P-9710 (Gigahertz-Optik). It is controlled via its RS232 interface. " +
"Measurement results are logged in a file.";
help.AddPreOptionsLine(preamble);
help.AddPreOptionsLine("");
help.AddPreOptionsLine($"Usage: {AppName} [options]");
help.AddPostOptionsLine("");
help.AddOptions(this);
return help;
}
}
}