1- function Get-NovaCliBaseInvocationData {
1+ function Get-NovaCliResolvedInvocationContext {
22 [CmdletBinding ()]
33 param (
4+ [Parameter (Mandatory )][string ]$Command ,
5+ [AllowEmptyCollection ()][string []]$Arguments = @ (),
46 [Parameter (Mandatory )][hashtable ]$CommonParameters ,
57 [Parameter (Mandatory )][hashtable ]$MutatingCommonParameters ,
68 [Parameter (Mandatory )][string ]$ModuleName ,
7- [Parameter (Mandatory )][bool ]$WhatIfEnabled
9+ [Parameter (Mandatory )][bool ]$WhatIfEnabled ,
10+ [Parameter (Mandatory )][bool ]$CliConfirmEnabled ,
11+ [AllowNull ()][pscustomobject ]$HelpRequest = $null
812 )
913
1014 return [pscustomobject ]@ {
15+ Command = $Command
16+ Arguments = @ ($Arguments )
1117 CommonParameters = $CommonParameters
1218 MutatingCommonParameters = $MutatingCommonParameters
19+ IsHelpRequest = $null -ne $HelpRequest
20+ HelpRequest = $HelpRequest
1321 ModuleName = $ModuleName
1422 WhatIfEnabled = $WhatIfEnabled
23+ CliConfirmEnabled = $CliConfirmEnabled
1524 }
1625}
1726
18- function Get-NovaCliHelpInvocationContext {
27+ function Get-NovaCliInvocationWhatIfState {
1928 [CmdletBinding ()]
2029 param (
21- [Parameter (Mandatory )][pscustomobject ]$HelpRequest ,
22- [Parameter (Mandatory )][pscustomobject ]$BaseInvocationData
30+ [switch ]$WhatIfEnabled ,
31+ [Parameter (Mandatory )][hashtable ]$MutatingCommonParameters ,
32+ [switch ]$RoutingWhatIfEnabled
2333 )
2434
25- return [pscustomobject ]@ {
26- Command = $HelpRequest.Command
27- Arguments = @ ()
28- CommonParameters = $BaseInvocationData.CommonParameters
29- MutatingCommonParameters = $BaseInvocationData.MutatingCommonParameters
30- IsHelpRequest = $true
31- HelpRequest = $HelpRequest
32- ModuleName = $BaseInvocationData.ModuleName
33- WhatIfEnabled = $BaseInvocationData.WhatIfEnabled
34- CliConfirmEnabled = $false
35- }
35+ return $WhatIfEnabled.IsPresent -or $RoutingWhatIfEnabled.IsPresent -or $MutatingCommonParameters.ContainsKey (' WhatIf' )
3636}
3737
38- function Get-NovaCliConfirmState {
38+ function Get-NovaCliInvocationConfirmState {
3939 [CmdletBinding ()]
4040 param (
4141 [Parameter (Mandatory )][hashtable ]$MutatingCommonParameters
@@ -50,27 +50,6 @@ function Get-NovaCliConfirmState {
5050 return $cliConfirmEnabled
5151}
5252
53- function Get-NovaCliRoutedInvocationContext {
54- [CmdletBinding ()]
55- param (
56- [Parameter (Mandatory )][pscustomobject ]$RoutingState ,
57- [Parameter (Mandatory )][pscustomobject ]$BaseInvocationData ,
58- [Parameter (Mandatory )][bool ]$CliConfirmEnabled
59- )
60-
61- return [pscustomobject ]@ {
62- Command = $RoutingState.Command
63- Arguments = $RoutingState.Arguments
64- CommonParameters = $BaseInvocationData.CommonParameters
65- MutatingCommonParameters = $BaseInvocationData.MutatingCommonParameters
66- IsHelpRequest = $false
67- HelpRequest = $null
68- ModuleName = $BaseInvocationData.ModuleName
69- WhatIfEnabled = $BaseInvocationData.WhatIfEnabled
70- CliConfirmEnabled = $CliConfirmEnabled
71- }
72- }
73-
7453function Get-NovaCliInvocationContext {
7554 [CmdletBinding ()]
7655 param (
@@ -85,22 +64,22 @@ function Get-NovaCliInvocationContext {
8564 Assert-NovaCliArgumentSyntax - Arguments (@ ($InvocationRequest.Command ) + $normalizedArguments )
8665 $helpRequest = Get-NovaCliHelpRequest - Command $InvocationRequest.Command - Arguments $normalizedArguments
8766 $moduleName = $ExecutionContext.SessionState.Module.Name
88- $helpBaseInvocationData = Get-NovaCliBaseInvocationData - CommonParameters $commonParameters - MutatingCommonParameters $mutatingCommonParameters - ModuleName $moduleName - WhatIfEnabled:( $WhatIfEnabled.IsPresent -or $mutatingCommonParameters.ContainsKey ( ' WhatIf ' ))
67+ $whatIfState = Get-NovaCliInvocationWhatIfState - WhatIfEnabled:$WhatIfEnabled - MutatingCommonParameters $mutatingCommonParameters
8968
9069 if ($null -ne $helpRequest ) {
91- return Get-NovaCliHelpInvocationContext - HelpRequest $helpRequest - BaseInvocationData $helpBaseInvocationData
70+ return Get-NovaCliResolvedInvocationContext - Command $helpRequest.Command - Arguments @ () - CommonParameters $commonParameters - MutatingCommonParameters $mutatingCommonParameters - ModuleName $moduleName - WhatIfEnabled: $whatIfState - CliConfirmEnabled: $false - HelpRequest $helpRequest
9271 }
9372
9473 $routingState = Get-NovaCliArgumentRoutingState - Command $InvocationRequest.Command - Arguments $normalizedArguments
95- $cliConfirmEnabled = Get-NovaCliConfirmState - MutatingCommonParameters $mutatingCommonParameters
74+ $cliConfirmEnabled = Get-NovaCliInvocationConfirmState - MutatingCommonParameters $mutatingCommonParameters
9675
9776 if ( $routingState.ForwardedParameters.ContainsKey (' Verbose' )) {
9877 $commonParameters.Verbose = $true
9978 }
10079
10180 $mutatingCommonParameters = Merge-NovaCliParameterSet - BaseParameters $mutatingCommonParameters - AdditionalParameters $routingState.ForwardedParameters
10281 $cliConfirmEnabled = $cliConfirmEnabled -or $routingState.CliConfirmEnabled
103- $routedBaseInvocationData = Get-NovaCliBaseInvocationData - CommonParameters $commonParameters - MutatingCommonParameters $mutatingCommonParameters - ModuleName $moduleName - WhatIfEnabled:( $WhatIfEnabled .IsPresent -or $ routingState.WhatIfEnabled -or $mutatingCommonParameters .ContainsKey ( ' WhatIf ' ))
82+ $whatIfState = Get-NovaCliInvocationWhatIfState - WhatIfEnabled: $WhatIfEnabled - MutatingCommonParameters $mutatingCommonParameters - RoutingWhatIfEnabled: $ routingState.WhatIfEnabled
10483
105- return Get-NovaCliRoutedInvocationContext - RoutingState $routingState - BaseInvocationData $routedBaseInvocationData - CliConfirmEnabled:$cliConfirmEnabled
84+ return Get-NovaCliResolvedInvocationContext - Command $routingState.Command - Arguments $routingState .Arguments - CommonParameters $commonParameters - MutatingCommonParameters $mutatingCommonParameters - ModuleName $moduleName - WhatIfEnabled: $whatIfState - CliConfirmEnabled:$cliConfirmEnabled
10685}
0 commit comments