fix(cmd): add error handling for user input in edit and lint commands
Some checks failed
CI / Test (push) Successful in 27s
CI / Lint (push) Successful in 18s
CI / Build (push) Failing after 33s

- Handle errors from fmt.Scanln in cmd/edit.go and cmd/lint.go to prevent crashes on input failures, providing user feedback and preserving backups.
- Update .gitea/workflows/release.yml to use 'ubuntu-gitea' runner for CI consistency.
This commit is contained in:
Greg Gauthier 2026-03-01 14:14:55 +00:00
parent ec5c43163b
commit cdcbd245d7
3 changed files with 11 additions and 3 deletions

View File

@ -11,7 +11,7 @@ permissions:
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
runs-on: ubuntu-gitea
steps:
- name: Checkout code
uses: actions/checkout@v4

View File

@ -71,7 +71,11 @@ var editCmd = &cobra.Command{
fmt.Print("\n\nApply these changes? (y/n): ")
var confirm string
fmt.Scanln(&confirm)
if _, err := fmt.Scanln(&confirm); err != nil {
color.Red("Failed to read input: %v", err)
color.Yellow("Changes discarded. Backup saved as %s", backupPath)
return
}
if confirm != "y" && confirm != "Y" {
color.Yellow("Changes discarded. Backup saved as %s", backupPath)
return

View File

@ -165,7 +165,11 @@ func runLint(cmd *cobra.Command, args []string) {
// Ask for confirmation
color.Yellow("Apply these fixes? (y/N): ")
var response string
fmt.Scanln(&response)
if _, err := fmt.Scanln(&response); err != nil {
logger.Info("failed to read user input", "file", absPath, "error", err)
color.Yellow("❌ Cancelled. Backup preserved at: %s", backupPath)
return
}
response = strings.ToLower(strings.TrimSpace(response))
if response != "y" && response != "yes" {