1
0
Fork 0
mirror of https://github.com/shouptech/tempgopher.git synced 2026-02-03 08:39:43 +00:00

Refactor PromptForConfiguration to accept io.Reader

This commit is contained in:
Emma 2018-10-26 10:10:40 -06:00
parent 281af2b255
commit 14b5cc4a8b

7
cli.go
View file

@ -3,6 +3,7 @@ package main
import (
"bufio"
"fmt"
"io"
"os"
"strconv"
"strings"
@ -40,8 +41,8 @@ func ParsePort(addr string) (uint16, error) {
}
// PromptForConfiguration walks a user through configuration
func PromptForConfiguration() Config {
reader := bufio.NewReader(os.Stdin)
func PromptForConfiguration(in io.Reader) Config {
reader := bufio.NewReader(in)
var config Config
@ -243,7 +244,7 @@ func ConfigCLI(path string) {
os.Exit(1)
}
config := PromptForConfiguration()
config := PromptForConfiguration(os.Stdin)
SaveConfig(path, config)
}