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

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: Comments 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 // ShowDebug controls whether or not calls to terminal.Debug produce output.
16 var ShowDebug = false
17
18 // Print prints the given format string (and arguments) to standard out.
19 func Print(format string, args ...interface{}) {
20 fmt.Printf(format, args)
21 }
22
23 // Debug is the same as Print, but only produces output if ShowDebug is true.
24 func Debug(format string, args ...interface{}) {
25 if ShowDebug {
26 fmt.Printf(format, args)
27 }
28 }
29
30 // Prompt prints a string to standard out, then waits for a single line
31 // of user input and returns it.
32 func Prompt(prompt string) string {
33 fmt.Print(prompt)
34 reader := bufio.NewReader(os.Stdin)
35 text, _ := reader.ReadString('\n')
36 return text
37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698