Skip to content

Commit 4fedda8

Browse files
committed
Hide pos from joblist if not used
1 parent a0c6def commit 4fedda8

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

commands/Jobs.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,31 @@ func (cData *CommandData) ListJobs(limit int) {
3636

3737
// Build header
3838
headingColor := color.New(color.FgHiGreen, color.Underline, color.Bold)
39-
header := []interface{}{headingColor.Sprint("ID"), headingColor.Sprint("Info"), headingColor.Sprint("Pos"), headingColor.Sprint("Job Type"), headingColor.Sprint("Upload Type"), headingColor.Sprint("Status")}
39+
header := []interface{}{headingColor.Sprint("ID"), headingColor.Sprint("Info")}
40+
var jobWithPos bool
41+
if hasJobWithPos(jobs.Jobs) {
42+
header = append(header, headingColor.Sprint("Pos"))
43+
jobWithPos = true
44+
}
45+
header = append(header, []interface{}{headingColor.Sprint("Job Type"), headingColor.Sprint("Upload Type"), headingColor.Sprint("Status")}...)
46+
4047
table.AddRow(header...)
4148

4249
// Fill table with data
4350
for _, job := range jobs.Jobs {
4451
rowitems := []interface{}{
4552
job.ID,
4653
job.Info,
47-
job.Position,
54+
}
55+
56+
if jobWithPos {
57+
rowitems = append(rowitems, job.Position)
58+
}
59+
60+
rowitems = append(rowitems, []interface{}{
4861
job.BuildType,
4962
job.UploadType,
50-
}
63+
}...)
5164

5265
if job.Status == librb.JobRunning {
5366
rowitems = append(rowitems, "Started "+humanTime.Difference(time.Now(), job.RunningSince))

commands/utils.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"syscall"
1919

2020
libdm "github.com/JojiiOfficial/LibRemotebuild"
21+
libremotebuild "github.com/JojiiOfficial/LibRemotebuild"
2122
"github.com/JojiiOfficial/gaw"
2223
"github.com/fatih/color"
2324
"golang.org/x/crypto/ssh/terminal"
@@ -257,3 +258,13 @@ func nameFromURL(u *url.URL) string {
257258
}
258259
return name
259260
}
261+
262+
func hasJobWithPos(jobs []libremotebuild.JobInfo) bool {
263+
for i := range jobs {
264+
if jobs[i].Position > 0 {
265+
return true
266+
}
267+
}
268+
269+
return false
270+
}

0 commit comments

Comments
 (0)