Program.cs 882 B

1234567891011121314151617181920212223242526272829303132333435
  1. using CustomHostingDemo.Logging;
  2. using Microsoft.Extensions.Logging;
  3. using Ninject;
  4. using System.CommandLine;
  5. using System.CommandLine.Builder;
  6. using System.CommandLine.Parsing;
  7. namespace CustomHostingDemo
  8. {
  9. class Program
  10. {
  11. static int Main(string[] args)
  12. {
  13. var kernel = new StandardKernel(
  14. new ConfigurationModule(),
  15. new LoggingModule(),
  16. new CommandHandlerModule()
  17. );
  18. var logger = kernel.Get<Logger<Program>>();
  19. logger.LogWarning("Hello");
  20. var rootCommand = new RootCommand()
  21. {
  22. new HelloCommand().Bind(kernel),
  23. };
  24. var parser = new CommandLineBuilder(rootCommand)
  25. .UseDefaults()
  26. .Build();
  27. return parser.InvokeAsync(args).Result;
  28. }
  29. }
  30. }