Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: print most things to stderr instead of stdout #515

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
Loading