Skip to content

Commit

Permalink
Add usage for --format-compact option
Browse files Browse the repository at this point in the history
  • Loading branch information
zalenskivolt committed Apr 24, 2023
1 parent d6856e6 commit afbf0f7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func Run(name string, args []string) error {
case err != nil:
usage(os.Stderr, name, flags)
return err
case opts.formatOptions.CompactPkgNameFormat == "help":
testjson.CompactFormatUsage(os.Stderr, name)
return nil
}
opts.args = flags.Args()
setupLogging(opts)
Expand Down Expand Up @@ -144,7 +147,7 @@ Formats:
dots print a character for each test
dots-v2 experimental dots format, one package per line
pkgname print a line for each package
pkgname-compact print multiple packages per line in a compact format
pkgname-compact print multiple packages per line, see --format-compact help for options
testname print a line for each test and package
standard-quiet standard go test format
standard-verbose standard go test -v format
Expand Down
2 changes: 1 addition & 1 deletion cmd/testdata/gotestsum-help-text
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Formats:
dots print a character for each test
dots-v2 experimental dots format, one package per line
pkgname print a line for each package
pkgname-compact print multiple packages per line in a compact format
pkgname-compact print multiple packages per line, see --format-compact help for options
testname print a line for each test and package
standard-quiet standard go test format
standard-verbose standard go test -v format
Expand Down
12 changes: 12 additions & 0 deletions testjson/compactformat.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package testjson

import (
"bufio"
"fmt"
"io"
"os"
"regexp"
Expand All @@ -16,6 +17,17 @@ import (

const CompactFormats = "relative, short, partial, partial-back"

func CompactFormatUsage(out io.Writer, name string) {
fmt.Fprintf(out, `
Formats:
relative (default) print the full relative path to the package
short print the last path segment of the package
partial print newly entered path segments for each package
partial-back partial with an indication when it backs out
`)
}

type PkgTracker struct {
opts FormatOptions
lastPkg string
Expand Down

0 comments on commit afbf0f7

Please sign in to comment.