diff --git a/go.mod b/go.mod index 8d079f4..5e9b42b 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( github.com/smartystreets/goconvey v1.6.4 // indirect github.com/stretchr/testify v1.7.0 // indirect github.com/urfave/cli/v2 v2.3.0 + golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect gopkg.in/ini.v1 v1.62.0 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect diff --git a/internal/txlib/utils.go b/internal/txlib/utils.go index 3ee6c33..e42af3f 100644 --- a/internal/txlib/utils.go +++ b/internal/txlib/utils.go @@ -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/crypto/ssh/terminal" ) func figureOutBranch(branch string) string { @@ -213,6 +214,10 @@ func isValidResolutionPolicy(policy string) (IsValid bool) { func truncateMessage(message string) string { maxLength := 80 + width, _, err := terminal.GetSize(int(os.Stdout.Fd())) + if err != nil && width > 0 { + maxLength = width + } if len(message) > maxLength { return message[:maxLength-2] + ".." }