Skip to content

Commit 2e8d251

Browse files
authored
refactor: optimize alias output (#408)
1 parent 6cd7837 commit 2e8d251

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

cmd/kubevpn/cmds/alias.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmds
22

33
import (
4+
"errors"
45
"fmt"
56
"io"
67
"os"
@@ -94,14 +95,14 @@ func CmdAlias(f cmdutil.Factory) *cobra.Command {
9495
if err != nil {
9596
return err
9697
}
97-
for _, config := range configs {
98-
c := exec.Command(name, config.Flags...)
98+
for _, conf := range configs {
99+
c := exec.Command(name, conf.Flags...)
99100
c.Stdout = os.Stdout
100101
c.Stdin = os.Stdin
101102
c.Stderr = os.Stderr
102-
fmt.Printf("Alias: %s\n", config.Name)
103-
if config.Description != "" {
104-
fmt.Printf("Description: %s\n", config.Description)
103+
fmt.Printf("Name: %s\n", conf.Name)
104+
if conf.Description != "" {
105+
fmt.Printf("Description: %s\n", conf.Description)
105106
}
106107
fmt.Printf("Command: %v\n", c.Args)
107108
err = c.Run()
@@ -149,7 +150,7 @@ func ParseAndGet(localFile, remoteAddr string, aliasName string) ([]Config, erro
149150
names = append(names, c.Name)
150151
}
151152
}
152-
err = fmt.Errorf("failed to find any aliases for the name: '%s', avaliable: [%s], please verify your configuration file %s", aliasName, strings.Join(names, ", "), path)
153+
err = errors.New(fmt.Sprintf("Can't find any alias for the name: '%s', avaliable: \n[\"%s\"]\nPlease check config file: %s", aliasName, strings.Join(names, "\", \""), path))
153154
return nil, err
154155
}
155156
return configs, nil

0 commit comments

Comments
 (0)