Skip to content

Commit

Permalink
Improve line truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwhitaker committed Jul 22, 2024
1 parent 67b0044 commit d48e1b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions runny/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ func (c *Config) PrintCommands() {

slices.Sort(names)
var separator = " "
var maxCommandLength = 60
maxLineLength := 80
if !term.IsTerminal(int(os.Stdout.Fd())) {
separator = "\t"
maxCommandLength = 40
maxLineLength = 40
}

for _, name := range names {
maxCommandLength := maxLineLength - len(name) - 1
var rawCommand = commandStringToSingleLine(commands[name].Run, maxCommandLength)

fmt.Print(primaryColor.Sprint(name))
Expand Down
2 changes: 1 addition & 1 deletion runny/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func commandStringToSingleLine(command string, maxlength int) string {
}
result := strings.Join(trimmedLines, "; ")
if len(result) > maxlength {
result = result[:maxlength-3] + "..."
result = result[:maxlength-1] + ""
}
return result
}
Expand Down

0 comments on commit d48e1b6

Please sign in to comment.