| Index: go/src/infra/tools/cr/lib/terminal/terminal.go
|
| diff --git a/go/src/infra/tools/cr/lib/terminal/terminal.go b/go/src/infra/tools/cr/lib/terminal/terminal.go
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7ef0eb041b42e464a30fc4ef55c20ca6f4bd2b69
|
| --- /dev/null
|
| +++ b/go/src/infra/tools/cr/lib/terminal/terminal.go
|
| @@ -0,0 +1,40 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +// Package terminal provides utilities for printing to and reading user input
|
| +// from an interactive terminal.
|
| +package terminal
|
| +
|
| +import (
|
| + "bufio"
|
| + "fmt"
|
| + "os"
|
| +)
|
| +
|
| +var showDebug = false
|
| +
|
| +func ToggleDebug() {
|
| + showDebug = !showDebug
|
| +}
|
| +
|
| +func SetDebug(show bool) {
|
| + showDebug = show
|
| +}
|
| +
|
| +func Print(format string, args ...interface{}) {
|
| + fmt.Printf(format, args)
|
| +}
|
| +
|
| +func Debug(format string, args ...interface{}) {
|
| + if showDebug {
|
| + fmt.Printf(format, args)
|
| + }
|
| +}
|
| +
|
| +func Prompt(prompt string) string {
|
| + fmt.Print(prompt)
|
| + reader := bufio.NewReader(os.Stdin)
|
| + text, _ := reader.ReadString('\n')
|
| + return text
|
| +}
|
|
|