diff --git a/cmd/subcmd_init.go b/cmd/subcmd_init.go index 8966bb1..7ef903f 100644 --- a/cmd/subcmd_init.go +++ b/cmd/subcmd_init.go @@ -1,6 +1,7 @@ package main import ( + "bufio" "fmt" "os" "path/filepath" @@ -32,8 +33,9 @@ var cmd_init = &cobra.Command{ // Get all the config values get_val := func(prompt string, val *string) { fmt.Printf("%s (%q): ", prompt, *val) - input := "" - Must(fmt.Scanln(&input)) + scanner := bufio.NewScanner(os.Stdin) + scanner.Scan() + input := scanner.Text() if input != "" { *val = input } diff --git a/ops/gas_init_test.sh b/ops/gas_init_test.sh new file mode 100755 index 0000000..5ea4328 --- /dev/null +++ b/ops/gas_init_test.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# ------------------ +# This is a test script that initializes a new project. +# ------------------ + + +set -e +set -x + +PS4='+(${BASH_SOURCE}:${LINENO}): ' +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +# Compile `gas` +gas="/tmp/gas" +go build -o $gas ./cmd + +test_project="/memory/test_gasproj" +if [[ -e $test_project ]]; then + rm -r "$test_project" +fi + +$gas init "$test_project" <