mirror of
https://github.com/ddworken/hishtory.git
synced 2025-02-02 11:39:24 +01:00
Display the hostname in the table
This commit is contained in:
parent
5c508e7cfc
commit
97670c92f5
@ -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()
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user