| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Package terminal provides utilities for printing to and reading user input |
| 6 // from an interactive terminal. |
| 7 package terminal |
| 8 |
| 9 import ( |
| 10 "bufio" |
| 11 "fmt" |
| 12 "os" |
| 13 ) |
| 14 |
| 15 var showDebug = false |
| 16 |
| 17 func ToggleDebug() { |
| 18 showDebug = !showDebug |
| 19 } |
| 20 |
| 21 func SetDebug(show bool) { |
| 22 showDebug = show |
| 23 } |
| 24 |
| 25 func Print(format string, args ...interface{}) { |
| 26 fmt.Printf(format, args) |
| 27 } |
| 28 |
| 29 func Debug(format string, args ...interface{}) { |
| 30 if showDebug { |
| 31 fmt.Printf(format, args) |
| 32 } |
| 33 } |
| 34 |
| 35 func Prompt(prompt string) string { |
| 36 fmt.Print(prompt) |
| 37 reader := bufio.NewReader(os.Stdin) |
| 38 text, _ := reader.ReadString('\n') |
| 39 return text |
| 40 } |
| OLD | NEW |