fix signature and make better chaining
This commit is contained in:
@@ -71,6 +71,10 @@ func BaseQuestions(interfaceType task.InterfaceType) taskui.Questions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Question(fields ...huh.Field) *huh.Group {
|
||||||
|
return huh.NewGroup(fields...)
|
||||||
|
}
|
||||||
|
|
||||||
func ReplQuestion(interfaceType task.InterfaceType, fields ...huh.Field) *huh.Group {
|
func ReplQuestion(interfaceType task.InterfaceType, fields ...huh.Field) *huh.Group {
|
||||||
if interfaceType != InterfaceREPL {
|
if interfaceType != InterfaceREPL {
|
||||||
return nil
|
return nil
|
||||||
@@ -78,14 +82,14 @@ func ReplQuestion(interfaceType task.InterfaceType, fields ...huh.Field) *huh.Gr
|
|||||||
return huh.NewGroup(fields...)
|
return huh.NewGroup(fields...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WebQuestion(questions *taskui.Questions, interfaceType task.InterfaceType, fields ...huh.Field) *huh.Group {
|
func WebQuestion(interfaceType task.InterfaceType, fields ...huh.Field) *huh.Group {
|
||||||
if interfaceType != InterfaceWeb {
|
if interfaceType != InterfaceWeb {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return huh.NewGroup(fields...)
|
return huh.NewGroup(fields...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TUIQuestion(questions *taskui.Questions, interfaceType task.InterfaceType, fields ...huh.Field) *huh.Group {
|
func TUIQuestion(interfaceType task.InterfaceType, fields ...huh.Field) *huh.Group {
|
||||||
if interfaceType != InterfaceTUI {
|
if interfaceType != InterfaceTUI {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,9 +40,21 @@ func (t *CodingTask) Details() taskui.TaskDetails {
|
|||||||
|
|
||||||
func (t *CodingTask) Questions(interfaceType task.InterfaceType) (questions taskui.Questions) {
|
func (t *CodingTask) Questions(interfaceType task.InterfaceType) (questions taskui.Questions) {
|
||||||
return BaseQuestions(interfaceType).
|
return BaseQuestions(interfaceType).
|
||||||
With(ReplQuestion(interfaceType,
|
With(
|
||||||
huh.NewInput().Title("Please write your code in the 'code.txt' file and save it.").
|
ReplQuestion(interfaceType,
|
||||||
Placeholder("Write your code here...")),
|
huh.NewConfirm().Title("Question only for REPL interface")),
|
||||||
|
).
|
||||||
|
With(
|
||||||
|
WebQuestion(interfaceType,
|
||||||
|
huh.NewInput().Title("Question only for Web interface")),
|
||||||
|
).
|
||||||
|
With(
|
||||||
|
TUIQuestion(interfaceType,
|
||||||
|
huh.NewConfirm().Title("Question only for TUI interface")),
|
||||||
|
).
|
||||||
|
With(
|
||||||
|
Question(
|
||||||
|
huh.NewConfirm().Title("One last question for all interfaces!")),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user