OptionComponent.cs 556 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using CommandLine;
  3. namespace ETModel
  4. {
  5. [ObjectSystem]
  6. public class OptionComponentSystem : AwakeSystem<OptionComponent, string[]>
  7. {
  8. public override void Awake(OptionComponent self, string[] a)
  9. {
  10. self.Awake(a);
  11. }
  12. }
  13. public class OptionComponent : Component
  14. {
  15. public Options Options { get; set; }
  16. public void Awake(string[] args)
  17. {
  18. Parser.Default.ParseArguments<Options>(args)
  19. .WithNotParsed(error => throw new Exception($"命令行格式错误!"))
  20. .WithParsed(options => { Options = options; });
  21. }
  22. }
  23. }