Skip to content

Commit

Permalink
[terminal] Added flag 'AlwaysYes'
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Aug 2, 2023
1 parent 0ef0ce6 commit f980a4a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

### 12.75.0

* `[terminal]` Added flag `AlwaysYes`, if set `ReadAnswer` will always return true without reading user input (_useful for working with option for forced actions_)

### 12.74.0

* `[timeutil]` Added method `PrettyDurationSimple` for printing duration in simple format
Expand Down
2 changes: 1 addition & 1 deletion ek.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
// ////////////////////////////////////////////////////////////////////////////////// //

// VERSION is current ek package version
const VERSION = "12.74.0"
const VERSION = "12.75.0"

// ////////////////////////////////////////////////////////////////////////////////// //

Expand Down
8 changes: 8 additions & 0 deletions terminal/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ var (
InfoPrefix = ""
)

// AlwaysYes is a flag, if set ReadAnswer will always return true (useful for working
// with option for forced actions)
var AlwaysYes = false

// ////////////////////////////////////////////////////////////////////////////////// //

var tmux int8
Expand All @@ -86,6 +90,10 @@ func Read(title string, nonEmpty bool) (string, error) {

// ReadAnswer reads user's answer for yes/no question
func ReadAnswer(title string, defaultAnswers ...string) (bool, error) {
if AlwaysYes {
return true, nil
}

var defaultAnswer string

if len(defaultAnswers) != 0 {
Expand Down
4 changes: 4 additions & 0 deletions terminal/terminal_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ var (
InfoPrefix = ""
)

// ❗ AlwaysYes is a flag, if set ReadAnswer will always return true (useful for working
// with option for forced actions)
var AlwaysYes = false

// ////////////////////////////////////////////////////////////////////////////////// //

// ❗ Read reads user's input
Expand Down

0 comments on commit f980a4a

Please sign in to comment.