~wrycode/DWCHelper

eefcd76f0dce1a27168fa1966757fdf86bdd1425 — Nick Econopouly 11 months ago 399fef4
Add Prompt function
2 files changed, 28 insertions(+), 1 deletions(-)

M DWCHelper.go
M lib.go
M DWCHelper.go => DWCHelper.go +2 -1
@@ 167,9 167,10 @@ func removeHelper(db database) []string {
		}
	}
	
	fmt.Println(`First we will clean up your list of terms. 
	Prompt(true,`First we will clean up your list of terms. 
The following terms are either empty (no data), or the value is the same for every 
specimen:`)

//asff
printStringSlice(termsToRemove)
	fmt.Println("Would you like to delete them?")

M lib.go => lib.go +26 -0
@@ 6,6 6,8 @@ import (
	"strconv"
	"bufio"
	"fmt"
	"time"
	"strings"
)
// Index returns the first index of the target string t, or -1 if no
// match is found


@@ 84,3 86,27 @@ func printStringSlice(terms []string) {
	fmt.Println()
}

// Prompt prints out the given string, and asks for user confirmation
// to continue is ask is set to true
func Prompt(ask bool, s string) {
	b := bufio.NewScanner(strings.NewReader(s))
		time.Sleep(100 * time.Millisecond)


	for b.Scan() {
		time.Sleep(100 * time.Millisecond)
		fmt.Println(b.Text())
	}
	if ask {
		r := bufio.NewReader(os.Stdin)
		time.Sleep(100 * time.Millisecond)
		fmt.Println("Press Enter to continue...")
		for {
			_, err := r.Peek(1) 
			if err == nil {
				return
			}
		}
	}
}