35 lines
899 B
Go
35 lines
899 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
type TUIConfig struct {
|
|
HistoryLimit int `mapstructure:"history_limit"`
|
|
}
|
|
type ActivityConfig struct {
|
|
Enabled bool `mapstructure:"enabled"`
|
|
RetentionDays int `mapstructure:"retention_days"`
|
|
MaxEntries int `mapstructure:"max_entries"`
|
|
}
|
|
|
|
func (c *Config) ValidateOperations() error {
|
|
if c.TUI.HistoryLimit < 0 {
|
|
return fmt.Errorf("tui.history_limit must be >= 0 (0 = all)")
|
|
}
|
|
if c.Activity.RetentionDays < 0 || c.Activity.MaxEntries < 0 {
|
|
return fmt.Errorf("activity retention_days and max_entries must be >= 0")
|
|
}
|
|
return nil
|
|
}
|
|
func (m SSHMatch) Matches(host SSHHost) bool { return m == (SSHMatch{}) || m.matches(host) }
|
|
func (c HostCommand) Allowed(host SSHHost) bool { return c.Match.Matches(host) }
|
|
func HookCommand(s string) string {
|
|
s = strings.TrimSpace(s)
|
|
if strings.EqualFold(s, "none") {
|
|
return ""
|
|
}
|
|
return s
|
|
}
|