feat(format-servers): add json format option

This commit is contained in:
Quentin McGaw
2024-08-16 10:13:55 +00:00
parent 01aaf2c86a
commit 1f2882434a
5 changed files with 92 additions and 47 deletions

View File

@@ -46,19 +46,18 @@ func (s *Storage) GetServersCount(provider string) (count int) {
return len(serversObject.Servers)
}
// FormatToMarkdown Markdown formats the servers for the provider given
// Format formats the servers for the provider using the format given
// and returns the resulting string.
func (s *Storage) FormatToMarkdown(provider string) (formatted string) {
func (s *Storage) Format(provider, format string) (formatted string, err error) {
if provider == providers.Custom {
return ""
return "", nil
}
s.mergedMutex.RLock()
defer s.mergedMutex.RUnlock()
serversObject := s.getMergedServersObject(provider)
formatted = serversObject.ToMarkdown(provider)
return formatted
return serversObject.Format(provider, format)
}
// GetServersCount returns the number of servers for the provider given.