in pkg/util/commandNotFound.go [30:60]
func CommandNotFound(c *cli.Context, s string) {
suppose := make([]string, 0)
var parentCommand string
if len(c.Lineage()) == 1 {
parentCommand = "swctl"
} else {
parentCommand = c.Lineage()[1].Args().First()
}
fmt.Printf("Error: unknown command \"%s\" for \"%s\" \n\n", s, parentCommand)
// Record commands whose edit distance is less than GAP to suppose.
for index := range c.App.Commands {
commandName := c.App.Commands[index].Name
distance := minEditDistance(commandName, s)
if distance <= GAP && commandName != "help" {
suppose = append(suppose, commandName)
}
}
if len(suppose) != 0 {
fmt.Println("Do you mean this?")
for index := range suppose {
fmt.Printf("\t%s\n", suppose[index])
}
fmt.Println()
}
if len(c.Lineage()) == 1 {
fmt.Printf("Run '%s --help' for usage.\n", parentCommand)
} else {
fmt.Printf("Run 'swctl %s --help' for usage.\n", parentCommand)
}
os.Exit(1)
}