Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
foteinigk committed Aug 7, 2024
1 parent 5567324 commit 2cb7624
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion internal/txlib/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/mattn/go-isatty"
"github.com/transifex/cli/internal/txlib/config"
"github.com/transifex/cli/pkg/jsonapi"
"golang.org/x/term"
)

func figureOutBranch(branch string) string {
Expand Down Expand Up @@ -209,9 +210,23 @@ func isValidResolutionPolicy(policy string) (IsValid bool) {

}

// Define a type for the function signature
type getSizeFuncType func(fd int) (int, int, error)

// Package-level variable holding the function to get terminal size
var getSizeFunc getSizeFuncType = term.GetSize

func truncateMessage(message string) string {
width, _, err := getSizeFunc(int(os.Stdout.Fd()))
if err != nil {
width = 80
}

maxLength := width - 2
if maxLength < 0 {
maxLength = 0
}

maxLength := 80
if len(message) > maxLength {
return message[:maxLength-2] + ".."
}
Expand Down

0 comments on commit 2cb7624

Please sign in to comment.