mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
43 lines
958 B
Go
43 lines
958 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"reflect"
|
|
"slices"
|
|
"strings"
|
|
)
|
|
|
|
// Report returns global config values as a table for reporting.
|
|
func (c Options) Report() (rows [][]string, cols []string) {
|
|
v := reflect.ValueOf(c)
|
|
|
|
cols = []string{"Name", "Type", "CLI Flag"}
|
|
rows = make([][]string, 0, v.NumField())
|
|
|
|
// Iterate through all config fields.
|
|
for i := 0; i < v.NumField(); i++ {
|
|
fieldValue := v.Field(i)
|
|
|
|
yamlName := v.Type().Field(i).Tag.Get("yaml")
|
|
flagName := v.Type().Field(i).Tag.Get("flag")
|
|
|
|
if yamlName == "" || yamlName == "-" || flagName == "" {
|
|
continue
|
|
}
|
|
|
|
// Skip options by feature set if tags are set.
|
|
if tags := v.Type().Field(i).Tag.Get("tags"); tags == "" {
|
|
// Report.
|
|
} else if !slices.Contains(strings.Split(tags, ","), Features) {
|
|
// Skip.
|
|
continue
|
|
}
|
|
|
|
fieldType := fmt.Sprintf("%T", fieldValue.Interface())
|
|
|
|
rows = append(rows, []string{yamlName, fieldType, "--" + flagName})
|
|
}
|
|
|
|
return rows, cols
|
|
}
|