diff --git a/main.go b/main.go index 58cb37f..8083720 100644 --- a/main.go +++ b/main.go @@ -130,6 +130,14 @@ func main() { distance = append(distance, JaroWinkler(command, args[0], 1, 0)) } + // Deals with shortcuts + for index, shortcut := range shortcuts { + // If the first argument is a shortcut and similarTo does not already contain its mapping, append it + if args[0] == shortcut && !Contains(similarTo, shortcutMappings[index]) { + similarTo = append(similarTo, shortcutMappings[index]) + } + } + // Compares each distance to the max of the distance slice and appends the closest command to similarTo for index, element := range distance { // If current element is the closest to the first argument @@ -139,14 +147,6 @@ func main() { } } - // Deals with shortcuts - for index, shortcut := range shortcuts { - // If the first argument is a shortcut and similarTo does not already contain its mapping, append it - if args[0] == shortcut && !Contains(similarTo, shortcutMappings[index]) { - similarTo = append(similarTo, shortcutMappings[index]) - } - } - // If similarTo is still empty, log it fatally as something is wrong with the config or the code if len(similarTo) == 0 { log.Fatalln("This command does not match any known commands or shortcuts") }