mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-24 14:01:46 +02:00
Make the custom column display code support entries that lack a newly configured custom column
This commit is contained in:
parent
ef8695ec86
commit
10d26fa407
@ -397,12 +397,18 @@ func AddToDbIfNew(db *gorm.DB, entry data.HistoryEntry) {
|
||||
}
|
||||
}
|
||||
|
||||
func getCustomColumnValue(header string, entry *data.HistoryEntry) (string, error) {
|
||||
func getCustomColumnValue(ctx *context.Context, header string, entry *data.HistoryEntry) (string, error) {
|
||||
for _, c := range entry.CustomColumns {
|
||||
if strings.EqualFold(c.Name, header) {
|
||||
return c.Val, nil
|
||||
}
|
||||
}
|
||||
config := hctx.GetConf(ctx)
|
||||
for _, c := range config.CustomColumns {
|
||||
if strings.EqualFold(c.ColumnName, header) {
|
||||
return "", nil
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("failed to find a column matching the column name %#v (is there a typo?)", header)
|
||||
}
|
||||
|
||||
@ -434,7 +440,7 @@ func DisplayResults(ctx *context.Context, results []*data.HistoryEntry) error {
|
||||
case "Command":
|
||||
row = append(row, result.Command)
|
||||
default:
|
||||
customColumnValue, err := getCustomColumnValue(header, result)
|
||||
customColumnValue, err := getCustomColumnValue(ctx, header, result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user