cmd: add option to get and set policy directly from database (#2765)
This commit is contained in:
parent
2938d03878
commit
2b30a15a68
10 changed files with 365 additions and 126 deletions
24
hscontrol/util/prompt.go
Normal file
24
hscontrol/util/prompt.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// YesNo takes a question and prompts the user to answer the
|
||||
// question with a yes or no. It appends a [y/n] to the message.
|
||||
// The question is written to stderr so that content can be redirected
|
||||
// without interfering with the prompt.
|
||||
func YesNo(msg string) bool {
|
||||
fmt.Fprint(os.Stderr, msg+" [y/n] ")
|
||||
|
||||
var resp string
|
||||
fmt.Scanln(&resp)
|
||||
resp = strings.ToLower(resp)
|
||||
switch resp {
|
||||
case "y", "yes", "sure":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue