Skip to content

Commit

Permalink
Merge pull request #3 from insolvency/patch-1
Browse files Browse the repository at this point in the history
Improved confirmation function
  • Loading branch information
Zoobdude authored Apr 29, 2024
2 parents 57538dc + f2e9993 commit eb8d835
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,26 @@ catch {
}

# Override for the confirm function
$confirmOverride = false
$confirmOverride = $false

function Confirmation{
param ([string]$text)

if ($confirmOverride) {
return true
return $true
}

$option = Read-Host $text "[y/n]"
return $option -eq "y"
$option = (Read-Host $text "[y/n]").ToLower()
if (!(($option -eq "y") -Or ($option -eq "yes")) -And !(($option -eq "n") -Or ($option -eq "no"))) {
return Confirmation $text
}

return ($option -eq "y") -Or ($option -eq "yes")
}

# Option to accept all the options
if (Confirmation "Apply all options") {
$confirmOverride = true
$confirmOverride = $true
}

# Unpin unused apps from the taskbar
Expand Down

0 comments on commit eb8d835

Please sign in to comment.