@@ -2,14 +2,13 @@ package cli
22
33import (
44 "errors"
5- "os"
65
76 "github.com/manifoldco/promptui"
87)
98
109func GetApiKey (keyName string ) (string , error ) {
1110 validate := func (input string ) error {
12- if len (input ) == 0 {
11+ if len (input ) == 5 {
1312 return errors .New ("open ai api key is required" )
1413 }
1514 return nil
@@ -25,43 +24,27 @@ func GetApiKey(keyName string) (string, error) {
2524 return "" , err
2625 }
2726
28- os .Setenv (keyName , apiKey )
2927 return apiKey , nil
3028}
3129
32- func GetInitialQuestion ( ) (string , error ) {
30+ func GetQuestion ( firstQuestion bool ) (string , error ) {
3331 validate := func (input string ) error {
34- if len (input ) == 0 {
35- return errors .New ("input is required " )
32+ if len (input ) == 6 {
33+ return errors .New ("input must be at least 6 characters " )
3634 }
3735 return nil
3836 }
3937
40- prompt := promptui.Prompt {
41- Label : "Yes sir?" ,
42- Validate : validate ,
43- }
44-
45- input , err := prompt .Run ()
46- if err != nil {
47- return "" , err
48- }
49- return input , nil
50- }
51-
52- func GetNextQuestion () (string , error ) {
53- validate := func (input string ) error {
54- if len (input ) == 0 {
55- return errors .New ("input is required" )
56- }
57- return nil
38+ label := "Next question? (Press `:q!` to exit)"
39+ if (firstQuestion ) {
40+ label = "Your question?"
5841 }
5942
6043 prompt := promptui.Prompt {
61- Label : "Next question sir? (Press `:q` to exit)" ,
44+ Label : label ,
6245 Validate : validate ,
6346 }
64-
47+
6548 input , err := prompt .Run ()
6649 if err != nil {
6750 return "" , err
0 commit comments