Skip to content

Commit

Permalink
fix: print most things to stderr instead of stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
lindell committed Dec 10, 2024
1 parent b5d20dc commit 3b5d760
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/cmd-print.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func printCMD(cmd *cobra.Command, _ []string) error {
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
fmt.Println("Finishing up ongoing runs. Press CTRL+C again to abort now.")
fmt.Fprintln(os.Stderr, "Finishing up ongoing runs. Press CTRL+C again to abort now.")
cancel()
<-c
os.Exit(1)
Expand All @@ -110,7 +110,7 @@ func printCMD(cmd *cobra.Command, _ []string) error {

err = printer.Print(ctx)
if err != nil {
fmt.Println(err.Error())
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/cmd-run.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func run(cmd *cobra.Command, _ []string) error {
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
fmt.Println("Finishing up ongoing runs. Press CTRL+C again to abort now.")
fmt.Fprintln(os.Stderr, "Finishing up ongoing runs. Press CTRL+C again to abort now.")
cancel()
<-c
os.Exit(1)
Expand Down Expand Up @@ -257,7 +257,7 @@ func run(cmd *cobra.Command, _ []string) error {

err = runner.Run(ctx)
if err != nil {
fmt.Println(err.Error())
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}

Expand Down
12 changes: 6 additions & 6 deletions internal/multigitter/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ func (r *Runner) ensurePullRequestExists(ctx context.Context, log log.FieldLogge
var interactiveInfo = `(V)iew changes. (A)ccept or (R)eject`

func (r *Runner) interactive(dir string, repo scm.Repository) error {
fmt.Printf("Changes were made to %s\n", terminal.Bold(repo.FullName()))
fmt.Println(interactiveInfo)
fmt.Fprintf(os.Stderr, "Changes were made to %s\n", terminal.Bold(repo.FullName()))
fmt.Fprintln(os.Stderr, interactiveInfo)
for {
char, key, err := keyboard.GetSingleKey()
if err != nil {
Expand All @@ -423,23 +423,23 @@ func (r *Runner) interactive(dir string, repo scm.Repository) error {

switch unicode.ToLower(char) {
case 'v':
fmt.Println("Showing changes...")
fmt.Fprintln(os.Stderr, "Showing changes...")
cmd := exec.Command("git", "diff", "HEAD~1")
cmd.Dir = dir
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err != nil {
if cmd.Err != nil {
return err
}
err = cmd.Run()
if err != nil {
return err
}
case 'r':
fmt.Println("Rejected, continuing...")
fmt.Fprintln(os.Stderr, "Rejected, continuing...")
return errRejected
case 'a':
fmt.Println("Accepted, proceeding...")
fmt.Fprintln(os.Stderr, "Accepted, proceeding...")
return nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func main() {
cmd.BuildDate, _ = time.ParseInLocation(time.RFC3339, date, time.UTC)
cmd.Commit = commit
if err := cmd.RootCmd().Execute(); err != nil {
fmt.Println(err)
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}

0 comments on commit 3b5d760

Please sign in to comment.