add builders and chaining methods for various types and variables for better reusability and readability
This commit is contained in:
@@ -7,8 +7,6 @@ import (
|
||||
"github.com/charmbracelet/huh"
|
||||
)
|
||||
|
||||
type Questions []*huh.Group
|
||||
|
||||
type QuestionnaireModel struct {
|
||||
Questions
|
||||
form *huh.Form
|
||||
|
||||
@@ -10,13 +10,6 @@ import (
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
type TaskDetails struct {
|
||||
Title string
|
||||
Description string
|
||||
TimeToComplete string
|
||||
Difficulty string
|
||||
}
|
||||
|
||||
type TaskModel struct {
|
||||
TaskDetails
|
||||
keys TaskHelpKeys
|
||||
|
||||
39
pkg/task/ui/types.go
Normal file
39
pkg/task/ui/types.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package taskui
|
||||
|
||||
import "github.com/charmbracelet/huh"
|
||||
|
||||
type TaskDetails struct {
|
||||
Title string
|
||||
Description string
|
||||
TimeToComplete string
|
||||
Difficulty string
|
||||
}
|
||||
|
||||
func (td TaskDetails) WithTitle(title string) TaskDetails {
|
||||
td.Title = title
|
||||
return td
|
||||
}
|
||||
|
||||
func (td TaskDetails) WithDescription(description string) TaskDetails {
|
||||
td.Description = description
|
||||
return td
|
||||
}
|
||||
|
||||
func (td TaskDetails) WithTimeToComplete(time string) TaskDetails {
|
||||
td.TimeToComplete = time
|
||||
return td
|
||||
}
|
||||
|
||||
func (td TaskDetails) WithDifficulty(difficulty string) TaskDetails {
|
||||
td.Difficulty = difficulty
|
||||
return td
|
||||
}
|
||||
|
||||
type Questions []*huh.Group
|
||||
|
||||
func (q Questions) With(group *huh.Group) Questions {
|
||||
if group == nil {
|
||||
return q
|
||||
}
|
||||
return append(q, group)
|
||||
}
|
||||
Reference in New Issue
Block a user