OptionsComponent.cs 507 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using Base;
  3. using CommandLine;
  4. namespace Model
  5. {
  6. [ObjectEvent]
  7. public class OptionsComponentEvent : ObjectEvent<OptionsComponent>, IAwake<string[]>
  8. {
  9. public void Awake(string[] args)
  10. {
  11. this.GetValue().Awake(args);
  12. }
  13. }
  14. public class OptionsComponent: Component
  15. {
  16. public Options Options = new Options();
  17. public void Awake(string[] args)
  18. {
  19. if (!Parser.Default.ParseArguments(args, this.Options))
  20. {
  21. throw new Exception($"命令行格式错误!");
  22. }
  23. }
  24. }
  25. }