Update README and make column name matching more relaxed

This commit is contained in:
David Dworken 2023-10-18 19:17:05 -07:00
parent 8274534be1
commit 9efef65e3a
No known key found for this signature in database
2 changed files with 9 additions and 7 deletions

View File

@ -85,6 +85,8 @@ You can customize the columns that are displayed via `hishtory config-set displa
hishtory config-set displayed-columns CWD Command hishtory config-set displayed-columns CWD Command
``` ```
The list of supported columns are: `Hostname`, `CWD`, `Timestamp`, `Runtime`, `ExitCode`, `Command`, and `User`.
</details> </details>
<details> <details>

View File

@ -88,24 +88,24 @@ func BuildTableRow(ctx context.Context, columnNames []string, entry data.History
row := make([]string, 0) row := make([]string, 0)
for _, header := range columnNames { for _, header := range columnNames {
switch header { switch header {
case "Hostname": case "Hostname", "hostname":
row = append(row, entry.Hostname) row = append(row, entry.Hostname)
case "CWD": case "CWD", "cwd":
row = append(row, entry.CurrentWorkingDirectory) row = append(row, entry.CurrentWorkingDirectory)
case "Timestamp": case "Timestamp", "timestamp":
row = append(row, entry.StartTime.Local().Format(hctx.GetConf(ctx).TimestampFormat)) row = append(row, entry.StartTime.Local().Format(hctx.GetConf(ctx).TimestampFormat))
case "Runtime": case "Runtime", "runtime":
if entry.EndTime.UnixMilli() == 0 { if entry.EndTime.UnixMilli() == 0 {
// An EndTime of zero means this is a pre-saved entry that never finished // An EndTime of zero means this is a pre-saved entry that never finished
row = append(row, "N/A") row = append(row, "N/A")
} else { } else {
row = append(row, entry.EndTime.Local().Sub(entry.StartTime.Local()).Round(time.Millisecond).String()) row = append(row, entry.EndTime.Local().Sub(entry.StartTime.Local()).Round(time.Millisecond).String())
} }
case "Exit Code": case "Exit Code", "Exit_Code", "ExitCode", "exitcode":
row = append(row, fmt.Sprintf("%d", entry.ExitCode)) row = append(row, fmt.Sprintf("%d", entry.ExitCode))
case "Command": case "Command", "command":
row = append(row, entry.Command) row = append(row, entry.Command)
case "User": case "User", "user":
row = append(row, entry.LocalUsername) row = append(row, entry.LocalUsername)
default: default:
customColumnValue, err := getCustomColumnValue(ctx, header, entry) customColumnValue, err := getCustomColumnValue(ctx, header, entry)