Skip to content

Commit

Permalink
feat: pass throw error code
Browse files Browse the repository at this point in the history
v0.9.0
  • Loading branch information
dbohdan committed Dec 13, 2024
1 parent 0b99c98 commit 1f6f49b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package main
import (
"bufio"
"context"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -55,7 +56,7 @@ const (
defaultWait = -1
sparklineLowMaximum = 10000
usageDivisor = 1 << 20 // Report memory usage in binary megabytes.
version = "0.8.1"
version = "0.9.0"
)

var sparklineTicks = []rune{'▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'}
Expand Down Expand Up @@ -350,7 +351,16 @@ func main() {
cfg := parseArgs()

if err := run(cfg); err != nil {
fmt.Fprintln(os.Stderr, err)
if cfg.outputPath == defaultOutputPath && !cfg.newlines {
fmt.Fprintln(os.Stderr)
}

var exitErr *exec.ExitError
if errors.As(err, &exitErr) {
os.Exit(exitErr.ExitCode())
}

fmt.Fprintln(os.Stderr, "Error: ", err)
os.Exit(1)
}
}
Expand Down

0 comments on commit 1f6f49b

Please sign in to comment.