Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Side by Side Diff: go/src/infra/tools/cr/lib/terminal/terminal.go

Issue 1929153002: Add beginnings of new cr command (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698