12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- # Interactive command line mode
- function Interactive-Mode {
- while ($true) {
- Write-Host "`rEnter command (c: Clear log, p: Print errors, l: View log, t: Tail log, m: Copy error, q: Quit): " -NoNewline
- $cmd = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown").Character
- Write-Host # New line
- switch ($cmd) {
- 'c' {
- Clear-Content -Path "storage\logs\laravel.log"
- Write-Host "Log cleared."
- }
- 'p' {
- $errors = Get-Content "storage\logs\laravel.log" -Encoding UTF8 | Select-String "ERROR"
- if ($errors) {
- Write-Host
- Get-Content "storage\logs\laravel.log" -Encoding UTF8 | Select-String "ERROR"
- Write-Host
- } else {
- Write-Host "No errors found."
- }
- }
- 'l' {
- Get-Content "storage\logs\laravel.log" -Encoding UTF8 | Out-Host -Paging
- }
- 't' {
- Get-Content "storage\logs\laravel.log" -Encoding UTF8 -Wait -Tail 1000
- }
- 'q' {
- Write-Host "Exiting program"
- exit
- }
- 'm' {
- $errors = Get-Content "storage\logs\laravel.log" -Encoding UTF8 | Select-String "ERROR"
- if ($errors) {
- $firstError = Get-Content "storage\logs\laravel.log" -Encoding UTF8 | Select-String "ERROR" | Select-Object -First 1
- $clipboardText = "$firstError`n`nAbove is the error log. Please help me fix this bug."
- Set-Clipboard -Value $clipboardText
- Write-Host "Error message copied to clipboard. You can ask AI assistant for help."
- } else {
- Write-Host "No errors found."
- }
- }
- default {
- Write-Host "Invalid command. Use 'c' to clear log, 'p' to print errors, 'l' to view log, 't' to tail log, 'm' to copy error, 'q' to quit."
- }
- }
- }
- }
- # Run interactive mode
- Interactive-Mode
|