Skip to content

Commit

Permalink
Fixing 'Write-Output' result not showing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
AnasAlhwid committed Oct 24, 2024
1 parent ce76368 commit 85b9488
Showing 1 changed file with 34 additions and 33 deletions.
67 changes: 34 additions & 33 deletions src/windows/modules/Manage-Git.psm1
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Imports
Import-Module "$PSScriptRoot\Manage-Design.psm1" -Force
Import-Module "$PSScriptRoot\Manage-Windows.psm1" -Force

# Links:
$urlInstallWinGet = "https://github.com/AnasAlhwid/qatam-cli/blob/main/README.md#prerequisites"
Expand Down Expand Up @@ -44,8 +45,8 @@ function Get-GitInstallationStatus {
# Function: Check Git's version
function Get-GitVersion {

Write-Output "Checking Git version..."
Write-Output ""
Write-Output "Checking Git version..." | Out-Default
Write-Output "" | Out-Default

try {
# Fetching Git's version.
Expand All @@ -64,15 +65,15 @@ function Get-GitVersion {

$(Format-Shape -T " " -CT "|")
$(Format-Shape -T "-" -CT "*" -CTC "blue")
Write-Output ""
Write-Output "" | Out-Default
}
catch {
$(Format-Shape `
-M "!" `
-TC "yellow" `
-Str "Failed to find Git version." `
)
Write-Output $_.Exception.Message
Write-Output $_.Exception.Message | Out-Default
}
}

Expand All @@ -84,36 +85,36 @@ function Update-Git {
Write-Output "Checking Git updates..."

if ($PSCmdlet.ShouldProcess("Git", "Update Git using WinGet")) {
Write-Output ""
Write-Output "" | Out-Default
try {
$(Format-Shape `
-M "*" `
-TC "blue" `
-Str "Please be patient this may take a bit :)" `
)
Write-Output ""
Write-Output "" | Out-Default

# Fetching Git's updates using WinGet.
winget upgrade --id Git.Git -e --source winget
Write-Output ""
Write-Output "" | Out-Default
}
catch {
$(Format-Shape `
-M "!" `
-TC "yellow" `
-Str "Failed to check Git updates." `
)
Write-Output $_.Exception.Message
Write-Output $_.Exception.Message | Out-Default
}
}
else {
Write-Output ""
Write-Output "" | Out-Default
$(Format-Shape `
-M "x" `
-TC "red" `
-Str "Git update canceled." `
)
Write-Output ""
Write-Output "" | Out-Default
}
}

Expand All @@ -122,39 +123,39 @@ function Install-Git {
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
param ()

Write-Output "Installing Git..."
Write-Output "Installing Git..." | Out-Default

if ($PSCmdlet.ShouldProcess("Git", "Install Git using WinGet")) {
Write-Output ""
Write-Output "" | Out-Default
try {
$(Format-Shape `
-M "*" `
-TC "blue" `
-Str "Please be patient this may take a bit :)" `
)
Write-Output ""
Write-Output "" | Out-Default

# Install Git via: https://git-scm.com/download/win using WinGet.
winget install --id Git.Git -e --source winget
Write-Output ""
Write-Output "" | Out-Default
}
catch {
$(Format-Shape `
-M "!" `
-TC "yellow" `
-Str "Failed to install Git." `
)
Write-Output $_.Exception.Message
Write-Output $_.Exception.Message | Out-Default
}
}
else {
Write-Output ""
Write-Output "" | Out-Default
$(Format-Shape `
-M "x" `
-TC "red" `
-Str "Git installation canceled." `
)
Write-Output ""
Write-Output "" | Out-Default
}
}

Expand All @@ -163,39 +164,39 @@ function Uninstall-Git {
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
param ()

Write-Output "Uninstalling Git..."
Write-Output "Uninstalling Git..." | Out-Default

if ($PSCmdlet.ShouldProcess("Git", "Uninstall Git using WinGet")) {
Write-Output ""
Write-Output "" | Out-Default
try {
$(Format-Shape `
-M "*" `
-TC "blue" `
-Str "Please be patient this may take a bit :)" `
)
Write-Output ""
Write-Output "" | Out-Default

# Uninstalling Git using WinGet.
winget uninstall --id Git.Git -e --source winget
Write-Output ""
Write-Output "" | Out-Default
}
catch {
$(Format-Shape `
-M "!" `
-TC "yellow" `
-Str "Failed to uninstall Git." `
)
Write-Output $_.Exception.Message
Write-Output $_.Exception.Message | Out-Default
}
}
else {
Write-Output ""
Write-Output "" | Out-Default
$(Format-Shape `
-M "x" `
-TC "red" `
-Str "Git uninstallation canceled." `
)
Write-Output ""
Write-Output "" | Out-Default
}
}

Expand Down Expand Up @@ -339,7 +340,7 @@ function Select-Git {
-TC "yellow" `
-Str "Git is Not installed. Run: $(Format-Color -TC "green" -Str "qatam git install") to install it." `
)
Write-Output ""
Write-Output "" | Out-Default
}
}
{ $_ -in @("update", "upd") } {
Expand All @@ -357,7 +358,7 @@ function Select-Git {
-TC "yellow" `
-Str "Git is Not installed. Run: $(Format-Color -TC "green" -Str "qatam git install") to install it." `
)
Write-Output ""
Write-Output "" | Out-Default
}
}
else {
Expand All @@ -366,7 +367,7 @@ function Select-Git {
-TC "yellow" `
-Str "WinGet is Not installed. Visit: $(Format-Color -TC "gold" -Str "`e]8;;$urlInstallWinGet`e\qatam-cli/WinGet`e]8;;`e\.") to install it." `
)
Write-Output ""
Write-Output "" | Out-Default
}
}
{ $_ -in @("install", "i") } {
Expand All @@ -379,7 +380,7 @@ function Select-Git {
-TC "yellow" `
-Str "Git is installed. Run: $(Format-Color -TC "green" -Str "qatam git help") to see other Git commands." `
)
Write-Output ""
Write-Output "" | Out-Default
}
else {
# A function that install Git.
Expand All @@ -392,7 +393,7 @@ function Select-Git {
-TC "yellow" `
-Str "WinGet is Not installed. Visit: $(Format-Color -TC "gold" -Str "`e]8;;$urlInstallWinGet`e\qatam-cli/WinGet`e]8;;`e\.") to install it." `
)
Write-Output ""
Write-Output "" | Out-Default
}
}
{ $_ -in @("uninstall", "uni") } {
Expand All @@ -411,7 +412,7 @@ function Select-Git {
-Str "Git is Not installed. Run: $(Format-Color -TC "green" -Str "qatam git help") to see other Git commands." `
-F $(Clear-Format -F "green") `
)
Write-Output ""
Write-Output "" | Out-Default
}
}
else {
Expand All @@ -420,20 +421,20 @@ function Select-Git {
-TC "yellow" `
-Str "WinGet is Not installed. Visit: $(Format-Color -TC "gold" -Str "`e]8;;$urlInstallWinGet`e\qatam-cli/WinGet`e]8;;`e\.") to install it." `
)
Write-Output ""
Write-Output "" | Out-Default
}
}
{ $_ -in @("help", "h", "") } {
Show-GitHelp
Write-Output ""
Write-Output "" | Out-Default
}
default {
$(Format-Shape `
-M "!" `
-TC "yellow" `
-Str "Invalid command, run: $(Format-Color -TC "green" -Str "qatam git help") to see all Git commands." `
)
Write-Output ""
Write-Output "" | Out-Default
}
}
}
Expand Down

0 comments on commit 85b9488

Please sign in to comment.