summaryrefslogtreecommitdiff
path: root/internal/io/prompt/prompt.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/io/prompt/prompt.go')
-rw-r--r--internal/io/prompt/prompt.go13
1 files changed, 5 insertions, 8 deletions
diff --git a/internal/io/prompt/prompt.go b/internal/io/prompt/prompt.go
index 36ebdb5..e82132d 100644
--- a/internal/io/prompt/prompt.go
+++ b/internal/io/prompt/prompt.go
@@ -6,7 +6,7 @@ import (
"os"
"strings"
- "github.com/mimecast/dtail/internal/io/logger"
+ "github.com/mimecast/dtail/internal/io/dlog"
)
// Answer is a user input of a prompt question.
@@ -19,7 +19,8 @@ type Answer struct {
Callback func()
// Runs after Callback and after logging resumes
EndCallback func()
- AskAgain bool
+ // AskAgain can be used to not to ask again about the question.
+ AskAgain bool
}
// Prompt used for interactive user input.
@@ -30,7 +31,6 @@ type Prompt struct {
func (p *Prompt) askString() string {
var sb strings.Builder
-
sb.WriteString(p.question)
sb.WriteString("? (")
@@ -41,7 +41,6 @@ func (p *Prompt) askString() string {
sb.WriteString(strings.Join(ax, ","))
sb.WriteString("): ")
-
return sb.String()
}
@@ -58,7 +57,7 @@ func (p *Prompt) Add(answer Answer) {
// Ask a question.
func (p *Prompt) Ask() {
reader := bufio.NewReader(os.Stdin)
- logger.Pause()
+ dlog.Common.Pause()
for {
fmt.Print(p.askString())
@@ -68,9 +67,8 @@ func (p *Prompt) Ask() {
if a.Callback != nil {
a.Callback()
}
-
if !a.AskAgain {
- logger.Resume()
+ dlog.Common.Resume()
if a.EndCallback != nil {
a.EndCallback()
}
@@ -90,6 +88,5 @@ func (p *Prompt) answer(answerStr string) (*Answer, bool) {
default:
}
}
-
return nil, false
}