Dies ist eine experimentelle Umsetzung im folgenden aufgeführten Ziele. Wie es verwendet: - Start über `evcc configure` - Die Konfiguration wird in evcc.yaml geschrieben. Falls diese existiert kann ein alternativer Dateiname angegeben werden Was es kann: - Eine geführte Erstellung der Konfigurationsdatei - Direktes Testen ob die Konfiguration jedes Gerätes auch funktioniert - Konfigurationsabhängigkeiten durch direkte Konfiguration der Abhängigkeit lösen (z.B. Sponsorshipt required) - Konfiguration in für Anwender bekannte Informationen und möglichst wenig Informationseingabe zu ermöglichen, z.B. anhand von Produkten anstatt aus der Implementierungssicht - Bisherige Konfiguration funktioniert weiter
23 lines
388 B
Go
23 lines
388 B
Go
package templates
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
func yamlQuote(value string) string {
|
|
input := fmt.Sprintf("key: %s", value)
|
|
|
|
var res struct {
|
|
Value string `yaml:"key"`
|
|
}
|
|
|
|
if err := yaml.Unmarshal([]byte(input), &res); err != nil || value != res.Value {
|
|
quoted := strings.ReplaceAll(value, `'`, `''`)
|
|
return fmt.Sprintf("'%s'", quoted)
|
|
}
|
|
|
|
return value
|
|
}
|