From 97670c92f590ca037c328d95803406c612297dde Mon Sep 17 00:00:00 2001 From: David Dworken Date: Sat, 9 Apr 2022 14:52:10 -0700 Subject: [PATCH] Display the hostname in the table --- client/lib/lib.go | 13 +++---------- hishtory.go | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/client/lib/lib.go b/client/lib/lib.go index 34827c5..bc880a7 100644 --- a/client/lib/lib.go +++ b/client/lib/lib.go @@ -190,22 +190,15 @@ func AddToDbIfNew(db *gorm.DB, entry data.HistoryEntry) { } } -func DisplayResults(results []*data.HistoryEntry, displayHostname bool) { +func DisplayResults(results []*data.HistoryEntry) { headerFmt := color.New(color.FgGreen, color.Underline).SprintfFunc() - tbl := table.New("CWD", "Timestamp", "Runtime", "Exit Code", "Command") - if displayHostname { - tbl = table.New("Hostname", "CWD", "Timestamp", "Runtime", "Exit Code", "Command") - } + tbl := table.New("Hostname", "CWD", "Timestamp", "Runtime", "Exit Code", "Command") tbl.WithHeaderFormatter(headerFmt) for _, result := range results { timestamp := result.StartTime.Format("Jan 2 2006 15:04:05 MST") duration := result.EndTime.Sub(result.StartTime).Round(time.Millisecond).String() - if displayHostname { - tbl.AddRow(result.Hostname, result.CurrentWorkingDirectory, timestamp, duration, result.ExitCode, result.Command) - } else { - tbl.AddRow(result.CurrentWorkingDirectory, timestamp, duration, result.ExitCode, result.Command) - } + tbl.AddRow(result.Hostname, result.CurrentWorkingDirectory, timestamp, duration, result.ExitCode, result.Command) } tbl.Print() diff --git a/hishtory.go b/hishtory.go index a60a010..d6b7f40 100644 --- a/hishtory.go +++ b/hishtory.go @@ -97,7 +97,7 @@ func query(query string) { lib.CheckFatalError(displayBannerIfSet()) data, err := data.Search(db, query, 25) lib.CheckFatalError(err) - lib.DisplayResults(data, false) + lib.DisplayResults(data) } func displayBannerIfSet() error {