Skip to content

Commit

Permalink
Add non-interactive switch for Manual plugin (rmbolger#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
hhhuut authored May 13, 2021
1 parent 8974067 commit 770cab2
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Posh-ACME/Plugins/Manual.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function Add-DnsTxt {
[string]$RecordName,
[Parameter(Mandatory,Position=1)]
[string]$TxtValue,
[switch]$ManualNonInteractive,
[Parameter(ValueFromRemainingArguments)]
$ExtraParams
)
Expand All @@ -28,6 +29,9 @@ function Add-DnsTxt {
.PARAMETER TxtValue
The value of the TXT record.
.PARAMETER ManualNonInteractive
If set, prevents user-prompts. Useful for automation scenarios where user input is not possible.
.PARAMETER ExtraParams
This parameter can be ignored and is only used to prevent errors when splatting with more parameters than this function supports.
Expand All @@ -45,6 +49,7 @@ function Remove-DnsTxt {
[string]$RecordName,
[Parameter(Mandatory,Position=1)]
[string]$TxtValue,
[switch]$ManualNonInteractive,
[Parameter(ValueFromRemainingArguments)]
$ExtraParams
)
Expand All @@ -66,6 +71,9 @@ function Remove-DnsTxt {
.PARAMETER TxtValue
The value of the TXT record.
.PARAMETER ManualNonInteractive
If set, prevents user-prompts. Useful for automation scenarios where user input is not possible.
.PARAMETER ExtraParams
This parameter can be ignored and is only used to prevent errors when splatting with more parameters than this function supports.
Expand All @@ -79,6 +87,7 @@ function Remove-DnsTxt {
function Save-DnsTxt {
[CmdletBinding()]
param(
[switch]$ManualNonInteractive,
[Parameter(ValueFromRemainingArguments)]
$ExtraParams
)
Expand All @@ -97,7 +106,13 @@ function Save-DnsTxt {
# clear out the variable so we don't notify twice
Remove-Variable ManualTxtAdd -Scope Script

Read-Host -Prompt "Press any key to continue." | Out-Null
if (-not $ManualNonInteractive) {
Read-Host -Prompt "Press any key to continue." | Out-Null
}
else {
Write-Host "Non-interactive mode, starting wait."
Write-Host
}
}

if ($script:ManualTxtRemove -and $script:ManualTxtRemove.Count -gt 0) {
Expand All @@ -122,6 +137,9 @@ function Save-DnsTxt {
.DESCRIPTION
This function outputs the pending TXT records to be created and waits for user confirmation to continue.
.PARAMETER ManualNonInteractive
If set, prevents user-prompts. Useful for automation scenarios where user input is not possible.
.PARAMETER ExtraParams
This parameter can be ignored and is only used to prevent errors when splatting with more parameters than this function supports.
#>
Expand Down

0 comments on commit 770cab2

Please sign in to comment.