IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ParseErrorResult.cs
Go to the documentation of this file.
1using System;
2using System.CommandLine.Invocation;
3using System.CommandLine.IO;
4using System.CommandLine.Rendering;
5
7{
8
9 class ParseErrorResult : IInvocationResult
10 {
11
12 readonly int? _errorExitCode;
13
18 public ParseErrorResult(int? errorExitCode)
19 {
20 _errorExitCode = errorExitCode;
21 }
22
24 public void Apply(InvocationContext context)
25 {
26 var terminal = context.Console.GetTerminal();
27 if (terminal != null)
28 {
29 terminal.ResetColor();
30 terminal.ForegroundColor = ConsoleColor.Red;
31
32 foreach (var error in context.ParseResult.Errors)
33 terminal.Error.WriteLine(error.Message);
34
35 terminal.ResetColor();
36 }
37 else
38 {
39 foreach (var error in context.ParseResult.Errors)
40 context.Console.Error.WriteLine(error.Message);
41 }
42
43 context.ExitCode = _errorExitCode ?? 1;
44 }
45
46 }
47
48}
ParseErrorResult(int? errorExitCode)
Initializes a new instance.
void Apply(InvocationContext context)