chore: coding style
This commit is contained in:
parent
299ae032b5
commit
e61f825c51
3 changed files with 11 additions and 20 deletions
|
|
@ -303,7 +303,7 @@ func (c *CmdConfigure) configureMQTT(templateItem templates.Template) (map[strin
|
|||
required: false})
|
||||
|
||||
fmt.Println()
|
||||
fmt.Println("-------------------------------------------")
|
||||
fmt.Println("--------------------------------------------")
|
||||
|
||||
broker := fmt.Sprintf("%s:%s", host, port)
|
||||
|
||||
|
|
|
|||
|
|
@ -41,18 +41,15 @@ func (c *CmdConfigure) askConfigFailureNextStep() bool {
|
|||
|
||||
// select item from list
|
||||
func (c *CmdConfigure) askSelection(message string, items []string) (string, int, error) {
|
||||
selection := ""
|
||||
prompt := &survey.Select{
|
||||
Message: message,
|
||||
Options: items,
|
||||
}
|
||||
|
||||
var selection string
|
||||
err := c.surveyAskOne(prompt, &selection)
|
||||
if err == nil {
|
||||
return selection, funk.IndexOf(items, selection), nil
|
||||
}
|
||||
|
||||
return "", 0, err
|
||||
return selection, funk.IndexOf(items, selection), err
|
||||
}
|
||||
|
||||
// selectItem selects item from list
|
||||
|
|
@ -91,13 +88,12 @@ func (c *CmdConfigure) askChoice(label string, choices []string) (int, string) {
|
|||
|
||||
// askYesNo asks yes/no question, return true if yes is selected
|
||||
func (c *CmdConfigure) askYesNo(label string) bool {
|
||||
confirmation := false
|
||||
prompt := &survey.Confirm{
|
||||
Message: label,
|
||||
}
|
||||
|
||||
err := c.surveyAskOne(prompt, &confirmation)
|
||||
if err != nil {
|
||||
var confirmation bool
|
||||
if err := c.surveyAskOne(prompt, &confirmation); err != nil {
|
||||
c.log.FATAL.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -155,10 +151,6 @@ func (c *CmdConfigure) askValue(q question) string {
|
|||
return chargingModes[modeChoice]
|
||||
}
|
||||
|
||||
input := ""
|
||||
|
||||
var err error
|
||||
|
||||
validate := func(val interface{}) error {
|
||||
value := val.(string)
|
||||
if q.invalidValues != nil && funk.ContainsString(q.invalidValues, value) {
|
||||
|
|
@ -217,23 +209,22 @@ func (c *CmdConfigure) askValue(q question) string {
|
|||
help += fmt.Sprintf(" ("+c.localizedString("Value_Sample", nil)+": %s)", q.exampleValue)
|
||||
}
|
||||
|
||||
var prompt survey.Prompt
|
||||
if q.mask {
|
||||
prompt := &survey.Password{
|
||||
prompt = &survey.Password{
|
||||
Message: q.label,
|
||||
Help: help,
|
||||
}
|
||||
err = c.surveyAskOne(prompt, &input, survey.WithValidator(validate))
|
||||
|
||||
} else {
|
||||
prompt := &survey.Input{
|
||||
prompt = &survey.Input{
|
||||
Message: q.label,
|
||||
Default: q.defaultValue,
|
||||
Help: help,
|
||||
}
|
||||
err = c.surveyAskOne(prompt, &input, survey.WithValidator(validate))
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
var input string
|
||||
if err := c.surveyAskOne(prompt, &input, survey.WithValidator(validate)); err != nil {
|
||||
c.log.FATAL.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ func display(res []tasks.Result) {
|
|||
continue
|
||||
|
||||
default:
|
||||
host := ""
|
||||
var host string
|
||||
hosts, err := net.LookupAddr(hit.ResultDetails.IP)
|
||||
if err == nil && len(hosts) > 0 {
|
||||
host = strings.TrimSuffix(hosts[0], ".")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue