summaryrefslogtreecommitdiff
path: root/internal/prompt
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-10-18 22:30:10 +0300
committerPaul Buetow <paul@buetow.org>2024-10-18 22:30:10 +0300
commit49750f5fb56b94ce0ee7a86b833aa7abf6db66ae (patch)
tree521951312b2c2b00a76c8908405176a2f5d36c23 /internal/prompt
parent0ad3bbbfc1f2c126d0c9c7282958b5839192b49e (diff)
can edit files when they are too large
Diffstat (limited to 'internal/prompt')
-rw-r--r--internal/prompt/prompt.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/internal/prompt/prompt.go b/internal/prompt/prompt.go
index e9d35c1..bf5997d 100644
--- a/internal/prompt/prompt.go
+++ b/internal/prompt/prompt.go
@@ -12,24 +12,34 @@ import (
)
var (
- ErrAborted = errors.New("aborted")
- // TODO: Add edit functionality. 1. configure EDITOR, 2. fork EDITOR process on the given file.
+ ErrAborted = errors.New("aborted")
ErrEditContent = errors.New("edit content")
- contentColor = color.New(color.FgCyan, color.BgBlue, color.Bold).SprintFunc()
- dangerColor = color.New(color.FgWhite, color.BgRed, color.Bold).SprintFunc()
+ blue = color.New(color.FgCyan, color.BgBlue, color.Bold).PrintfFunc()
+ red = color.New(color.FgWhite, color.BgRed, color.Bold).PrintfFunc()
)
func DoYouWantThis(question, content string) error {
- fmt.Print(contentColor(content))
+ blue(content)
fmt.Print("\n")
return whatNow(question)
}
+func Acknowledge(message, content string) error {
+ blue(content)
+ fmt.Print("\n")
+ red(message + " (press enter)")
+ reader := bufio.NewReader(os.Stdin)
+ if _, err := reader.ReadString('\n'); err != nil {
+ return err
+ }
+ return nil
+}
+
func whatNow(question string) error {
reader := bufio.NewReader(os.Stdin)
for {
- fmt.Printf("%s ", dangerColor(fmt.Sprintf("%s (y=yes/n=no/e=edit):", question)))
+ red("%s (y=yes/n=no/e=edit):", question)
input, err := reader.ReadString('\n')
if err != nil {
fmt.Println("Error reading input:", err)