Skip to content

Commit

Permalink
Improved interactive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
roblaszczak committed Jan 31, 2022
1 parent 1811333 commit 9c40d97
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion internal/confirm.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ func FConfirmPromptDefaultYes(action string, stdin io.Reader, stdout io.Writer)

logrus.WithField("input", input).Debug("Received input")

if input == "n" || input == "no" || input == "q" || input == endOfTextChar {
if input == endOfTextChar {
clean()
os.Exit(0)
} else if input == "q" || input == "n" || input == "no" {
return false
} else if input == "\r" || input == "\n" || input == "" {
return true
Expand Down
6 changes: 3 additions & 3 deletions trainings/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ func (h *Handlers) showTrainingStartPrompt() error {
return errors.Wrap(err, "can't get wd")
}

msg := fmt.Sprintf(
"This command will clone training source code to %s directory. Do you want to continue?",
fmt.Printf(
"This command will clone training source code to %s directory.\n",
pwd,
)

if !internal.ConfirmPromptDefaultYes(msg) {
if !internal.ConfirmPromptDefaultYes("continue") {
return ErrInterrupted
}

Expand Down
1 change: 1 addition & 0 deletions trainings/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func (h *Handlers) run(ctx context.Context) (success bool, finished bool, err er

fmt.Println()
if !internal.ConfirmPromptDefaultYes("go to the next exercise") {
os.Exit(0)
return success, false, nil
}

Expand Down

0 comments on commit 9c40d97

Please sign in to comment.