File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 1
1
// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information.
2
-
2
+ using System ;
3
+ using System . IO ;
3
4
using System . Collections . Generic ;
4
5
using System . Linq ;
5
6
@@ -28,6 +29,15 @@ public static bool IsVersion(this IEnumerable<Error> errs)
28
29
return true ;
29
30
//when AutoVersion=false in parser, Version is disabled and Parser raise UnknownOptionError
30
31
return errs . Any ( x => ( x is UnknownOptionError ee ? ee . Token : "" ) == "version" ) ;
32
+ }
33
+ /// <summary>
34
+ /// redirect errs to Console.Error, and to Console.Out for help/version error
35
+ /// </summary>
36
+ public static TextWriter Output ( this IEnumerable < Error > errs )
37
+ {
38
+ if ( errs . IsHelp ( ) || errs . IsVersion ( ) )
39
+ return Console . Out ;
40
+ return Console . Error ;
31
41
}
32
42
}
33
43
}
You can’t perform that action at this time.
0 commit comments