Options.cs 854 B

12345678910111213141516171819202122232425262728293031
  1. using System.Text;
  2. using CommandLine;
  3. using Common.Network;
  4. namespace Common.Base
  5. {
  6. public class Options
  7. {
  8. [Option('h', "host", Required = true, HelpText = "Host.")]
  9. public string Host { get; set; }
  10. [Option('p', "port", Required = true, HelpText = "Port.")]
  11. public int Port { get; set; }
  12. [Option("protocol", Required = true, HelpText = "Protocol, tcp or udp.")]
  13. public NetworkProtocol Protocol { get; set; }
  14. [Option('v', null, HelpText = "Print details during execution.")]
  15. public bool Verbose { get; set; }
  16. [HelpOption]
  17. public string GetUsage()
  18. {
  19. // this without using CommandLine.Text
  20. StringBuilder usage = new StringBuilder();
  21. usage.AppendLine("Quickstart Application 1.0");
  22. usage.AppendLine("Read user manual for usage instructions...");
  23. return usage.ToString();
  24. }
  25. }
  26. }