Skip to content

Commit

Permalink
Moved all functions to near the beginning of the script.
Browse files Browse the repository at this point in the history
  • Loading branch information
trparky committed Dec 26, 2023
1 parent 70647d1 commit 6b462f7
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions bw_export.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,39 @@ try {
}
}

function ConvertSecureString {
param (
[System.Security.SecureString]$String
)

if ($String.Length -eq 0) { return "" }
else {
$output = ConvertFrom-SecureString -SecureString $String -AsPlainText
return $output.Trim()
}
}

function AskYesNoQuestion {
param (
[String]$prompt
)

$answer = ""
do {
$answer = (Read-Host $prompt).ToLower().Trim()
} while ($answer -ne 'y' -and $answer -ne 'n')

return $answer
}

function LockAndLogout {
./bw lock
Write-Host ""

./bw logout
Write-Host ""
}

if ($IsWindows) { $bwCliBinName = (Join-Path (Get-Location) "bw.exe") }
else { $bwCliBinName = (Join-Path (Get-Location) "bw") }

Expand Down Expand Up @@ -131,39 +164,6 @@ try {

if (!(Test-Path -Path $saveFolder)) { New-Item -ItemType Directory -Path $saveFolder | Out-Null }

function ConvertSecureString {
param (
[System.Security.SecureString]$String
)

if ($String.Length -eq 0) { return "" }
else {
$output = ConvertFrom-SecureString -SecureString $String -AsPlainText
return $output.Trim()
}
}

function AskYesNoQuestion {
param (
[String]$prompt
)

$answer = ""
do {
$answer = (Read-Host $prompt).ToLower().Trim()
} while ($answer -ne 'y' -and $answer -ne 'n')

return $answer
}

function LockAndLogout {
./bw lock
Write-Host ""

./bw logout
Write-Host ""
}

# Prompt user for their Bitwarden password
$bwPassword = Read-Host "Enter your Bitwarden Password" -AsSecureString

Expand Down

0 comments on commit 6b462f7

Please sign in to comment.