-
Notifications
You must be signed in to change notification settings - Fork 0
/
prompt.go
46 lines (34 loc) · 653 Bytes
/
prompt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package surveyexpect
// Prompt is a prompt expectation for a survey.
type Prompt interface {
Step
}
type basePrompt struct {
parent *Survey
repeatability int
// Amount of times this request has been executed.
totalCalls int
}
func (p *basePrompt) lock() {
p.parent.mu.Lock()
}
func (p *basePrompt) unlock() {
p.parent.mu.Unlock()
}
func (p *basePrompt) times(i int) {
p.lock()
defer p.unlock()
p.timesLocked(i)
}
func (p *basePrompt) timesLocked(i int) {
p.repeatability = i
}
func (p *basePrompt) isDoneLocked(err error) error {
if err != nil {
return err
}
if p.repeatability > 0 {
return ErrNotFinished
}
return nil
}