uninstallPowerShellCompletion uninstalls PowerShell completion
(verbose bool)
| 528 | |
| 529 | // uninstallPowerShellCompletion uninstalls PowerShell completion |
| 530 | func uninstallPowerShellCompletion(verbose bool) error { |
| 531 | shellCompletionLog.Print("Uninstalling PowerShell completion") |
| 532 | |
| 533 | // Determine PowerShell profile path |
| 534 | var profileCmd *exec.Cmd |
| 535 | if runtime.GOOS == "windows" { |
| 536 | profileCmd = exec.Command("powershell", "-NoProfile", "-Command", "echo $PROFILE") |
| 537 | } else { |
| 538 | profileCmd = exec.Command("pwsh", "-NoProfile", "-Command", "echo $PROFILE") |
| 539 | } |
| 540 | |
| 541 | var profileBuf bytes.Buffer |
| 542 | profileCmd.Stdout = &profileBuf |
| 543 | if err := profileCmd.Run(); err != nil { |
| 544 | return fmt.Errorf("failed to get PowerShell profile path: %w", err) |
| 545 | } |
| 546 | |
| 547 | profilePath := strings.TrimSpace(profileBuf.String()) |
| 548 | |
| 549 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("PowerShell profile path: "+profilePath)) |
| 550 | fmt.Fprintln(os.Stderr, "") |
| 551 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("To uninstall completions, remove the following line from your PowerShell profile:")) |
| 552 | fmt.Fprintln(os.Stderr, "") |
| 553 | fmt.Fprintln(os.Stderr, " gh aw completion powershell | Out-String | Invoke-Expression") |
| 554 | fmt.Fprintln(os.Stderr, "") |
| 555 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Then restart your shell or run: . $PROFILE")) |
| 556 | |
| 557 | return nil |
| 558 | } |
no test coverage detected