// userFriendlyTexts sets user friendly texts for a set of known param names and
// returns them as a new set as we don't want to overwrite the template values
userFriendlyTexts sets user friendly texts for a set of known param names and
returns them as a new set as we don't want to overwrite the template values
// userFriendlyTexts sets user friendly texts for a set of known param names and // returns them as a new set as we don ' t want to overwrite the template values
func (c *CmdConfigure) userFriendlyTexts(param templates.Param) templates.Param {
	result := param
	if result.ValueType == "" || (result.ValueType != "" && !funk.ContainsString(templates.ParamValueTypes, result.ValueType)) {
		result.ValueType = templates.ParamValueTypeString
	}
	type replacements struct {
		Name      string
		Help      string
		Example   string
		ValueType string
	}
	resultNameMap := map[string]replacements{
		"title":        {Name: "UserFriendly_Title_Name", Help: "UserFriendly_Title_Help"},
		"device":       {Name: "UserFriendly_Device_Name"},
		"baudrate":     {Name: "UserFriendly_Baudrate_Name"},
		"comset":       {Name: "UserFriendly_ComSet_Name"},
		"host":         {Name: "UserFriendly_Host_Name"},
		"port":         {Name: "UserFriendly_Port_Name", ValueType: templates.ParamValueTypeNumber},
		"user":         {Name: "UserFriendly_User_Name"},
		"password":     {Name: "UserFriendly_Password_Name"},
		"capacity":     {Name: "UserFriendly_Capacity_Name", Example: "41.5", ValueType: templates.ParamValueTypeFloat},
		"vin":          {Name: "UserFriendly_Vin_Name", Help: "UserFriendly_Vin_Help"},
		"cache":        {Name: "UserFriendly_Cache_Name", Help: "UserFriendly_Cache_Help", Example: "5m"},
		"mode":         {Name: "ChargeMode_Question", ValueType: templates.ParamValueTypeChargeModes},
		"minsoc":       {Name: "UserFriendly_MinSoC_Name", Help: "UserFriendly_MinSoC_Help", Example: "25", ValueType: templates.ParamValueTypeNumber},
		"targetsoc":    {Name: "UserFriendly_TargetSoC_Name", Help: "UserFriendly_TargetSoC_Help", Example: "80", ValueType: templates.ParamValueTypeNumber},
		"mincurrent":   {Name: "UserFriendly_MinCurrent_Name", Help: "UserFriendly_MinCurrent_Help", Example: "6", ValueType: templates.ParamValueTypeNumber},
		"maxcurrent":   {Name: "UserFriendly_MaxCurrent_Name", Help: "UserFriendly_MaxCurrent_Help", Example: "16", ValueType: templates.ParamValueTypeNumber},
		"identifiers":  {Name: "UserFriendly_Identifier_Name", Help: "UserFriendly_Identifier_Help"},
		"standbypower": {Name: "UserFriendly_StandByPower_Name", Help: "UserFriendly_StandByPower_Help", ValueType: templates.ParamValueTypeNumber},
	}
	if resultMapItem := resultNameMap[strings.ToLower(result.Name)]; resultMapItem != (replacements{}) {
		if resultMapItem.Name != "" {
			result.Name = c.localizedString(resultMapItem.Name, nil)
		}
		if resultMapItem.ValueType != "" {
			result.ValueType = resultMapItem.ValueType
		}
		if result.Help.String(c.lang) == "" && resultMapItem.Help != "" {
			result.Help.SetString(c.lang, c.localizedString(resultMapItem.Help, nil))
		}
		if result.Example == "" && resultMapItem.Example != "" {
			result.Example = resultMapItem.Example
		}
	}
	return result
}
func ( c * CmdConfigure ) userFriendlyTexts ( param templates . Param ) templates . Param { result := param if result . ValueType == " " || ( result . ValueType != " " && ! funk . ContainsString ( templates . ParamValueTypes , result . ValueType ) ) { result . ValueType = templates . ParamValueTypeString } type replacements struct { Name string Help string Example string ValueType string } resultNameMap := map [ string ] replacements { " " : { Name : " " , Help : " " } , " " : { Name : " " } , " " : { Name : " " } , " " : { Name : " " } , " " : { Name : " " } , " " : { Name : " " , ValueType : templates . ParamValueTypeNumber } , " " : { Name : " " } , " " : { Name : " " } , " " : { Name : " " , Example : " " , ValueType : templates . ParamValueTypeFloat } , " " : { Name : " " , Help : " " } , " " : { Name : " " , Help : " " , Example : " " } , " " : { Name : " " , ValueType : templates . ParamValueTypeChargeModes } , " " : { Name : " " , Help : " " , Example : " " , ValueType : templates . ParamValueTypeNumber } , " " : { Name : " " , Help : " " , Example : " " , ValueType : templates . ParamValueTypeNumber } , " " : { Name : " " , Help : " " , Example : " " , ValueType : templates . ParamValueTypeNumber } , " " : { Name : " " , Help : " " , Example : " " , ValueType : templates . ParamValueTypeNumber } , " " : { Name : " " , Help : " " } , " " : { Name : " " , Help : " " , ValueType : templates . ParamValueTypeNumber } , } if resultMapItem := resultNameMap [ strings . ToLower ( result . Name ) ] ; resultMapItem != ( replacements { } ) { if resultMapItem . Name != " " { result . Name = c . localizedString ( resultMapItem . Name , nil ) } if resultMapItem . ValueType != " " { result . ValueType = resultMapItem . ValueType } if result . Help . String ( c . lang ) == " " && resultMapItem . Help != " " { result . Help . SetString ( c . lang , c . localizedString ( resultMapItem . Help , nil ) ) } if result . Example == " " && resultMapItem . Example != " " { result . Example = resultMapItem . Example } } return result }
userFriendlyTexts sets user friendly texts for a set of known param names and
returns them as a new set as we don't want to overwrite the template values
userFriendlyTexts sets user friendly texts for a set of known param names and returns them as a new set as we don ' t want to overwrite the template values
// always overwrite if defined // only set if empty