fix(cmd): ignore fmt errors in output

Amolith and Crush created

Co-authored-by: Crush <crush@charm.land>

Change summary

cmd/g/g.go            |  4 ++--
cmd/g/s.go            | 14 +++++++-------
cmd/g/u.go            | 16 ++++++++--------
cmd/r.go              | 16 ++++++++--------
cmd/s.go              | 16 ++++++++--------
cmd/shared/helpers.go |  4 ++--
6 files changed, 35 insertions(+), 35 deletions(-)

Detailed changes

cmd/g/g.go 🔗

@@ -38,8 +38,8 @@ func runShowGoal(cmd *cobra.Command, _ []string) error {
 	}
 
 	if state.Goal == nil {
-		fmt.Fprintln(cmd.OutOrStdout(), "")
-		fmt.Fprintln(cmd.OutOrStdout(), "Set the goal with `np g s -t \"goal title\" -d \"goal description\"` to begin.")
+		_, _ = fmt.Fprintln(cmd.OutOrStdout(), "")
+		_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Set the goal with `np g s -t \"goal title\" -d \"goal description\"` to begin.")
 	}
 	return nil
 }

cmd/g/s.go 🔗

@@ -58,11 +58,11 @@ func runSetGoal(cmd *cobra.Command, _ []string) error {
 	description = strings.TrimSpace(description)
 
 	if title == "" {
-		fmt.Fprintln(cmd.OutOrStdout(), "Goal title is required.")
+		_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Goal title is required.")
 		return nil
 	}
 	if description == "" {
-		fmt.Fprintln(cmd.OutOrStdout(), "Goal description is required.")
+		_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Goal description is required.")
 		return nil
 	}
 
@@ -71,7 +71,7 @@ func runSetGoal(cmd *cobra.Command, _ []string) error {
 		return err
 	}
 	if exists {
-		fmt.Fprintln(cmd.OutOrStdout(), "Goal already set. Use 'np g u' to update it (requires -r/--reason flag).")
+		_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Goal already set. Use 'np g u' to update it (requires -r/--reason flag).")
 		return nil
 	}
 
@@ -102,10 +102,10 @@ func runSetGoal(cmd *cobra.Command, _ []string) error {
 	}
 
 	out := cmd.OutOrStdout()
-	fmt.Fprintln(out, "")
-	fmt.Fprintln(out, "Study the goal and its description carefully.")
-	fmt.Fprintln(out, "Review referenced tickets and files to gather context before planning changes.")
-	fmt.Fprintln(out, "Add tasks with `np t a -t \"task title\" -d \"details\"` once you understand the approach.")
+	_, _ = fmt.Fprintln(out, "")
+	_, _ = fmt.Fprintln(out, "Study the goal and its description carefully.")
+	_, _ = fmt.Fprintln(out, "Review referenced tickets and files to gather context before planning changes.")
+	_, _ = fmt.Fprintln(out, "Add tasks with `np t a -t \"task title\" -d \"details\"` once you understand the approach.")
 
 	return nil
 }

cmd/g/u.go 🔗

@@ -49,7 +49,7 @@ func runUpdateGoal(cmd *cobra.Command, _ []string) error {
 	current, err := env.GoalStore.Get(cmd.Context(), sessionDoc.SID)
 	if err != nil {
 		if errors.Is(err, goal.ErrNotFound) {
-			fmt.Fprintln(cmd.OutOrStdout(), "No goal set yet. Use 'np g s' first.")
+			_, _ = fmt.Fprintln(cmd.OutOrStdout(), "No goal set yet. Use 'np g s' first.")
 			return nil
 		}
 		return err
@@ -70,7 +70,7 @@ func runUpdateGoal(cmd *cobra.Command, _ []string) error {
 
 	reason = strings.TrimSpace(reason)
 	if reason == "" {
-		fmt.Fprintln(cmd.OutOrStdout(), "Reason is required for goal updates.")
+		_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Reason is required for goal updates.")
 		return nil
 	}
 
@@ -78,7 +78,7 @@ func runUpdateGoal(cmd *cobra.Command, _ []string) error {
 	if cmd.Flags().Changed("title") {
 		newTitle = strings.TrimSpace(titleInput)
 		if newTitle == "" {
-			fmt.Fprintln(cmd.OutOrStdout(), "Goal title cannot be empty.")
+			_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Goal title cannot be empty.")
 			return nil
 		}
 	}
@@ -89,12 +89,12 @@ func runUpdateGoal(cmd *cobra.Command, _ []string) error {
 	}
 
 	if !cmd.Flags().Changed("title") && !cmd.Flags().Changed("description") {
-		fmt.Fprintln(cmd.OutOrStdout(), "Provide at least one of --title or --description to update the goal.")
+		_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Provide at least one of --title or --description to update the goal.")
 		return nil
 	}
 
 	if newTitle == current.Title && newDescription == current.Description {
-		fmt.Fprintln(cmd.OutOrStdout(), "Goal already matches the provided values; no changes made.")
+		_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Goal already matches the provided values; no changes made.")
 		return nil
 	}
 
@@ -126,9 +126,9 @@ func runUpdateGoal(cmd *cobra.Command, _ []string) error {
 	}
 
 	out := cmd.OutOrStdout()
-	fmt.Fprintln(out, "")
-	fmt.Fprintln(out, "Goal updated. Ensure pending tasks still align and adjust them if necessary.")
-	fmt.Fprintln(out, "Add or update tasks with `np t a` / `np t u` so the plan reflects the new direction.")
+	_, _ = fmt.Fprintln(out, "")
+	_, _ = fmt.Fprintln(out, "Goal updated. Ensure pending tasks still align and adjust them if necessary.")
+	_, _ = fmt.Fprintln(out, "Add or update tasks with `np t a` / `np t u` so the plan reflects the new direction.")
 
 	return nil
 }

cmd/r.go 🔗

@@ -40,12 +40,12 @@ func runResume(cmd *cobra.Command, args []string) error {
 	}
 
 	// Print instructions for resuming work
-	fmt.Fprintln(cmd.OutOrStdout(), strings.Repeat("-", 80))
-	fmt.Fprintln(cmd.OutOrStdout(), "\nResuming session. To continue:")
-	fmt.Fprintln(cmd.OutOrStdout(), "1. Check the goal description above for any bug/issue/ticket ID. If present, read that ticket for full context.")
-	fmt.Fprintln(cmd.OutOrStdout(), "2. Read the files and symbols referenced in the pending tasks to understand what work remains.")
-	fmt.Fprintln(cmd.OutOrStdout(), "3. Update task status as you work: `np t u -i <task-id> -s <status>`")
-	fmt.Fprintln(cmd.OutOrStdout(), "   Statuses: pending, in_progress, completed, failed, cancelled")
+	_, _ = fmt.Fprintln(cmd.OutOrStdout(), strings.Repeat("-", 80))
+	_, _ = fmt.Fprintln(cmd.OutOrStdout(), "\nResuming session. To continue:")
+	_, _ = fmt.Fprintln(cmd.OutOrStdout(), "1. Check the goal description above for any bug/issue/ticket ID. If present, read that ticket for full context.")
+	_, _ = fmt.Fprintln(cmd.OutOrStdout(), "2. Read the files and symbols referenced in the pending tasks to understand what work remains.")
+	_, _ = fmt.Fprintln(cmd.OutOrStdout(), "3. Update task status as you work: `np t u -i <task-id> -s <status>`")
+	_, _ = fmt.Fprintln(cmd.OutOrStdout(), "   Statuses: pending, in_progress, completed, failed, cancelled")
 
 	// Provide context about pending work
 	pendingCount := 0
@@ -60,10 +60,10 @@ func runResume(cmd *cobra.Command, args []string) error {
 	}
 
 	if inProgressCount > 0 {
-		fmt.Fprintf(cmd.OutOrStdout(), "\n%d task(s) are in progress.\n", inProgressCount)
+		_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\n%d task(s) are in progress.\n", inProgressCount)
 	}
 	if pendingCount > 0 {
-		fmt.Fprintf(cmd.OutOrStdout(), "%d task(s) are pending.\n", pendingCount)
+		_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%d task(s) are pending.\n", pendingCount)
 	}
 
 	return nil

cmd/s.go 🔗

@@ -47,18 +47,18 @@ func runStartSession(cmd *cobra.Command, args []string) error {
 
 func printExistingSession(cmd *cobra.Command, existing session.Document) error {
 	out := cmd.OutOrStdout()
-	fmt.Fprintf(out, "Session %s is already active for %s.\n", existing.SID, existing.DirPath)
-	fmt.Fprintln(out, "There's already an active session for this directory; ask your operator whether they want to resume or archive it.")
+	_, _ = fmt.Fprintf(out, "Session %s is already active for %s.\n", existing.SID, existing.DirPath)
+	_, _ = fmt.Fprintln(out, "There's already an active session for this directory; ask your operator whether they want to resume or archive it.")
 	return nil
 }
 
 func printSessionStarted(cmd *cobra.Command, doc session.Document) {
 	out := cmd.OutOrStdout()
-	fmt.Fprintf(out, "Session %s is now active for %s.\n\n", doc.SID, doc.DirPath)
+	_, _ = fmt.Fprintf(out, "Session %s is now active for %s.\n\n", doc.SID, doc.DirPath)
 
-	fmt.Fprintln(out, "Set the goal immediately with `np g s -t \"goal title\" -d \"goal description\"`.")
-	fmt.Fprintln(out, "Include ticket numbers, file paths, and any other references inside the goal description.")
-	fmt.Fprintln(out, "Once the goal is set, read the referenced files and add tasks with `np t a -t \"task\" -d \"details\"`.")
-	fmt.Fprintln(out, "Keep task statuses up to date with `np t u -i task-id -s in_progress|completed|failed|cancelled` as you work.")
-	fmt.Fprintln(out, "Use `np p` whenever you need to review the full plan.")
+	_, _ = fmt.Fprintln(out, "Set the goal immediately with `np g s -t \"goal title\" -d \"goal description\"`.")
+	_, _ = fmt.Fprintln(out, "Include ticket numbers, file paths, and any other references inside the goal description.")
+	_, _ = fmt.Fprintln(out, "Once the goal is set, read the referenced files and add tasks with `np t a -t \"task\" -d \"details\"`.")
+	_, _ = fmt.Fprintln(out, "Keep task statuses up to date with `np t u -i task-id -s in_progress|completed|failed|cancelled` as you work.")
+	_, _ = fmt.Fprintln(out, "Use `np p` whenever you need to review the full plan.")
 }

cmd/shared/helpers.go 🔗

@@ -35,7 +35,7 @@ func ActiveSession(cmd *cobra.Command, env *cli.Environment) (session.Document,
 		return session.Document{}, false, err
 	}
 	if !found {
-		fmt.Fprintln(cmd.OutOrStdout(), "No active session. Start one with `np s`.")
+		_, _ = fmt.Fprintln(cmd.OutOrStdout(), "No active session. Start one with `np s`.")
 		return session.Document{}, false, nil
 	}
 	return doc, true, nil
@@ -53,6 +53,6 @@ func PrintPlan(cmd *cobra.Command, env *cli.Environment, sid string) (cli.PlanSt
 		return cli.PlanState{}, err
 	}
 
-	fmt.Fprintln(cmd.OutOrStdout(), cli.RenderPlan(state))
+	_, _ = fmt.Fprintln(cmd.OutOrStdout(), cli.RenderPlan(state))
 	return state, nil
 }