Skip to content

Commit c158776

Browse files
committed
Shorten file name output
1 parent c819079 commit c158776

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

note/note.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ type FileDetail struct {
162162
Status string
163163
}
164164

165+
func (f *FileDetail) ShortenSourceFile(n int) string {
166+
x := len(f.SourceFile) - n
167+
if x <= 0 {
168+
return f.SourceFile
169+
}
170+
return fmt.Sprintf("..%s", f.SourceFile[x:])
171+
}
172+
165173
// SortEpochs returns timeline keys sorted by epoch
166174
func (f *FileDetail) SortEpochs() []int64 {
167175
keys := []int64{}

report/templates.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const (
3434
{{- if $f.IsTerminal }}
3535
{{- FormatDuration $f.TimeSpent | printf "\n%14s" }} {{ Percent $f.TimeSpent $total | printf "%3.0f"}}% [{{ $f.Status }}] Terminal
3636
{{- else }}
37-
{{- FormatDuration $f.TimeSpent | printf "\n%14s" }} {{ Percent $f.TimeSpent $total | printf "%3.0f"}}% [{{ $f.Status }}] {{$f.SourceFile}}
37+
{{- FormatDuration $f.TimeSpent | printf "\n%14s" }} {{ Percent $f.TimeSpent $total | printf "%3.0f"}}% [{{ $f.Status }}] {{$f.ShortenSourceFile 40}}
3838
{{- end }}
3939
{{- end }}
4040
{{- if len .Note.Files }}
@@ -52,7 +52,7 @@ const (
5252
{{- if $f.IsTerminal }}
5353
{{- FormatDuration $f.TimeSpent | printf "%14s" }} {{ Percent $f.TimeSpent $total | printf "%3.0f"}}% [{{ $f.Status }}] Terminal
5454
{{- else }}
55-
{{- FormatDuration $f.TimeSpent | printf "%14s" }} {{ Percent $f.TimeSpent $total | printf "%3.0f"}}% [{{ $f.Status }}] {{$f.SourceFile}}
55+
{{- FormatDuration $f.TimeSpent | printf "%14s" }} {{ Percent $f.TimeSpent $total | printf "%3.0f"}}% [{{ $f.Status }}] {{$f.ShortenSourceFile 40}}
5656
{{- end }}
5757
{{ end }}
5858
{{- if len .Note.Files }}

0 commit comments

Comments
 (0)