Skip to content

Commit

Permalink
add enable cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiranAvidov committed Aug 31, 2023
1 parent c0ff80e commit 9a020e3
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
39 changes: 37 additions & 2 deletions scripts/windows/agent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,33 @@ function Get-AgentId {
}
}

# Gets enable cursor
# Input:
# FuncArgs - Hashtable {AgentArgs = $args}
# Output:
# EnableCursor - Tells if cursor should be enabled or not
function Get-EnableCursor {
param (
[hashtable]$FuncArgs
)

$local:Err = Test-AreFuncArgsExist $FuncArgs @('AgentArgs')
if ($Err.Count -ne 0) {
return
}

$local:AgentArgs = $FuncArgs.AgentArgs

foreach ($Arg in $AgentArgs) {
switch -Regex ($Arg) {
--enable-cursor {
"`$script:EnableCursor = `$true"
return
}
}
}
}

# Deletes Logz.io temp directory
# Input:
# ---
Expand Down Expand Up @@ -180,7 +207,6 @@ $script:AgentId = ''
# Settings
$ProgressPreference = 'SilentlyContinue'
$WarningPreference = 'SilentlyContinue'
[Console]::CursorVisible = $false

# Agent status flags
$script:IsInstallThreadJobModuleFailed = $false
Expand All @@ -190,6 +216,13 @@ $script:IsRemoveLastRunAnswerNo = $false
$script:IsAgentFailed = $false
$script:IsPostrequisiteFailed = $false
$script:IsAgentCompleted = $false
$script:EnableCursor = $false

# Get enable cursor
Get-EnableCursor @{AgentArgs = $args}
if (-Not $script:EnableCursor) {
[Console]::CursorVisible = $false
}

# Print main title
try {
Expand Down Expand Up @@ -305,5 +338,7 @@ finally {
Write-AgentFinalMessages
Remove-TempDir

[Console]::CursorVisible = $true
if (-Not $script:EnableCursor) {
[Console]::CursorVisible = $true
}
}
10 changes: 9 additions & 1 deletion scripts/windows/functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,12 @@ function Test-IsElevated {
# Output:
# Help usage
function Show-Help {
Write-TaskPostRun "Write-Host `"Usage: .\agent.ps1 --url=<logzio_app_url> --id=<agent_id> [--debug=<agent_json>] [--release<repo_release>]`""
Write-TaskPostRun "Write-Host `"Usage: .\agent.ps1 --url=<logzio_app_url> --id=<agent_id> [--debug=<agent_json>] [--release<repo_release>] [--enable-cursor]`""
Write-TaskPostRun "Write-Host ' --url=<logzio_app_url> Logz.io app URL (https://app.logz.io)'"
Write-TaskPostRun "Write-Host ' --id=<agent_id> Logz.io agent ID'"
Write-TaskPostRun "Write-Host ' --debug=<agent_json> Debug run using a local agent json file'"
Write-TaskPostRun "Write-Host ' --release=<repo_release> The release of Logz.io repo. Default is latest release'"
Write-TaskPostRun "Write-Host ' enable-cursor Will not '"
Write-TaskPostRun "Write-Host ' --help Show usage'"
}

Expand Down Expand Up @@ -252,6 +253,13 @@ function Get-Arguments {
Write-TaskPostRun "`$script:RepoRelease = '$RepoRelease'"
continue
}
--enable-cursor {
$Message = "Agent argument 'enable-cursor' was detected"
Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepPreInit $script:LogScriptAgent $FuncName $script:AgentId
Write-Log $script:LogLevelDebug $Message

continue
}
default {
$Message = "agent.ps1 ($ExitCode): unrecognized flag"
Send-LogToLogzio $script:LogLevelError $Message $script:LogStepPreInit $script:LogScriptAgent $FuncName $script:AgentId
Expand Down

0 comments on commit 9a020e3

Please sign in to comment.