1
1
// Copyright (c) .NET Foundation and contributors. All rights reserved.
2
2
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
4
- using System . Linq ;
5
4
using System . Threading ;
6
5
using System . Threading . Tasks ;
7
6
@@ -23,10 +22,9 @@ internal static async Task<int> InvokeAsync(ParseResult parseResult, Cancellatio
23
22
{
24
23
if ( parseResult . NonexclusiveActions is not null )
25
24
{
26
- for ( var i = 0 ; i < parseResult . NonexclusiveActions . Count ; i ++ )
25
+ for ( int i = 0 ; i < parseResult . NonexclusiveActions . Count ; i ++ )
27
26
{
28
- var action = parseResult . NonexclusiveActions [ i ] ;
29
- await action . InvokeAsync ( parseResult , cts . Token ) ;
27
+ await parseResult . NonexclusiveActions [ i ] . InvokeAsync ( parseResult , cts . Token ) ;
30
28
}
31
29
}
32
30
@@ -67,31 +65,21 @@ internal static int Invoke(ParseResult parseResult)
67
65
return ReturnCodeForMissingAction ( parseResult ) ;
68
66
}
69
67
70
- if ( parseResult . NonexclusiveActions is not null )
68
+ try
71
69
{
72
- for ( var i = 0 ; i < parseResult . NonexclusiveActions . Count ; i ++ )
70
+ if ( parseResult . NonexclusiveActions is not null )
73
71
{
74
- var action = parseResult . NonexclusiveActions [ i ] ;
75
- var result = TryInvokeAction ( parseResult , action ) ;
76
- if ( ! result . success )
72
+ for ( var i = 0 ; i < parseResult . NonexclusiveActions . Count ; i ++ )
77
73
{
78
- return result . returnCode ;
74
+ parseResult . NonexclusiveActions [ i ] . Invoke ( parseResult ) ;
79
75
}
80
76
}
81
- }
82
-
83
- return TryInvokeAction ( parseResult , parseResult . Action ) . returnCode ;
84
77
85
- static ( int returnCode , bool success ) TryInvokeAction ( ParseResult parseResult , CliAction action )
78
+ return parseResult . Action . Invoke ( parseResult ) ;
79
+ }
80
+ catch ( Exception ex ) when ( parseResult . Configuration . EnableDefaultExceptionHandler )
86
81
{
87
- try
88
- {
89
- return ( action . Invoke ( parseResult ) , true ) ;
90
- }
91
- catch ( Exception ex ) when ( parseResult . Configuration . EnableDefaultExceptionHandler )
92
- {
93
- return ( DefaultExceptionHandler ( ex , parseResult . Configuration ) , false ) ;
94
- }
82
+ return DefaultExceptionHandler ( ex , parseResult . Configuration ) ;
95
83
}
96
84
}
97
85
0 commit comments