Skip to content

Commit 98996a6

Browse files
committed
候補が1つに定まっている場合にユーザの入力が省略状態でも確定させて実行できるよう調整
1 parent 40cb68c commit 98996a6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cmd/trygolang/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func main() {
6666
break
6767
}
6868

69+
candidates = make([]string, 0, len(mapping))
6970
for k := range mapping {
7071
if strings.Contains(k, userInput) {
7172
candidates = append(candidates, k)
@@ -78,7 +79,9 @@ func main() {
7879
fmt.Printf("Not found...Try Again")
7980
goto nextinput
8081
case numberOfCandidate == 1:
82+
userInput = candidates[0]
8183
if v, ok := mapping[userInput]; ok {
84+
fmt.Printf("[Name] %q\n", userInput)
8285
if err := v(); err != nil {
8386
log.Fatal(err)
8487
}

0 commit comments

Comments
 (0)