Skip to content

Commit

Permalink
Enable cursor (#132)
Browse files Browse the repository at this point in the history
* add enable cursor

* fix

* will not what

* fix helm
  • Loading branch information
ShiranAvidov authored Sep 3, 2023
1 parent 496f4e9 commit 4460c27
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
34 changes: 32 additions & 2 deletions scripts/windows/agent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ 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: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 +202,6 @@ $script:AgentId = ''
# Settings
$ProgressPreference = 'SilentlyContinue'
$WarningPreference = 'SilentlyContinue'
[Console]::CursorVisible = $false

# Agent status flags
$script:IsInstallThreadJobModuleFailed = $false
Expand All @@ -190,6 +211,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 +333,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 Makes the cursor visible at all times'"
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 4460c27

Please sign in to comment.