package report import ( "fmt" "strings" ) const ( CommandNameDaily = "daily" CommandNameToday = "today" CommandNameTomorrow = "tomorrow" CommandNameHourly = "hourly" BatchNameMorning = "morning" BatchNameEvening = "evening" ) func IDForCommandName(name string) (ID, error) { switch name { case CommandNameDaily: return Daily, nil case CommandNameToday: return Today, nil case CommandNameTomorrow: return Tomorrow, nil case CommandNameHourly: return Hourly, nil default: return "", fmt.Errorf("unknown report command %q", name) } } func CommandNames() []string { return []string{ CommandNameDaily, CommandNameToday, CommandNameTomorrow, CommandNameHourly, } } func IDForConfigKey(key string) (ID, error) { normalized := strings.ReplaceAll(strings.TrimSpace(strings.ToLower(key)), "-", "_") switch normalized { case "daily": return Daily, nil case "today": return Today, nil case "tomorrow": return Tomorrow, nil case "hourly": return Hourly, nil default: return "", fmt.Errorf("report config key %q is not a known report", key) } } func BatchForCommandName(name string) (Batch, error) { switch name { case BatchNameMorning: return Morning, nil case BatchNameEvening: return Evening, nil default: return "", fmt.Errorf("unknown batch command %q", name) } } func BatchCommandNames() []string { return []string{ BatchNameMorning, BatchNameEvening, } }