|
@@ -67,7 +67,7 @@ type Model struct {
|
|
|
// The bubbletea init function
|
|
// The bubbletea init function
|
|
|
func (m Model) Init() tea.Cmd { return m.load }
|
|
func (m Model) Init() tea.Cmd { return m.load }
|
|
|
|
|
|
|
|
-// Handles quit logic and viewport scroll and size updates
|
|
|
|
|
|
|
+// Core tea.Model update loop
|
|
|
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|
|
// widget specifc keyhandling
|
|
// widget specifc keyhandling
|
|
|
var cmds []tea.Cmd
|
|
var cmds []tea.Cmd
|
|
@@ -177,7 +177,7 @@ type create struct {
|
|
|
Err error // not implemented
|
|
Err error // not implemented
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// constructor for createIssue widget
|
|
|
|
|
|
|
+// constructor for create widget
|
|
|
func initialCreateModel(path string, placeholder string) create {
|
|
func initialCreateModel(path string, placeholder string) create {
|
|
|
spawnInput := func(f bool) textinput.Model {
|
|
spawnInput := func(f bool) textinput.Model {
|
|
|
ti := textinput.New()
|
|
ti := textinput.New()
|
|
@@ -220,10 +220,12 @@ func initialCreateModel(path string, placeholder string) create {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// init cmd for create widget
|
|
|
func (c create) init() tea.Cmd {
|
|
func (c create) init() tea.Cmd {
|
|
|
return textinput.Blink
|
|
return textinput.Blink
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// update cmd for create widget
|
|
|
func (c create) update(msg tea.Msg) (create, tea.Cmd) {
|
|
func (c create) update(msg tea.Msg) (create, tea.Cmd) {
|
|
|
var cmds []tea.Cmd
|
|
var cmds []tea.Cmd
|
|
|
var cmd tea.Cmd
|
|
var cmd tea.Cmd
|
|
@@ -304,6 +306,7 @@ func (c create) update(msg tea.Msg) (create, tea.Cmd) {
|
|
|
return c, tea.Batch(cmds...)
|
|
return c, tea.Batch(cmds...)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// render cmd for create widget
|
|
|
func (c create) render() tea.Msg {
|
|
func (c create) render() tea.Msg {
|
|
|
borderStyle := lipgloss.NewStyle().
|
|
borderStyle := lipgloss.NewStyle().
|
|
|
BorderStyle(lipgloss.NormalBorder()).
|
|
BorderStyle(lipgloss.NormalBorder()).
|
|
@@ -338,6 +341,7 @@ func (c create) render() tea.Msg {
|
|
|
return output
|
|
return output
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// keyhelp cmd for create widget
|
|
|
func (c create) keyhelp() string {
|
|
func (c create) keyhelp() string {
|
|
|
var output string
|
|
var output string
|
|
|
output = output + "\ntab/shift+tab: down/up\t\tenter: input value\t\tctrl+c: quit"
|
|
output = output + "\ntab/shift+tab: down/up\t\tenter: input value\t\tctrl+c: quit"
|
|
@@ -347,7 +351,7 @@ func (c create) keyhelp() string {
|
|
|
// -------- Issue widget definitions ------------------------------------------
|
|
// -------- Issue widget definitions ------------------------------------------
|
|
|
// ----------------------------------------------------------------------------
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-// Handles all render logic for Issue structs
|
|
|
|
|
|
|
+// render cmd for Issue widget
|
|
|
func (i Issue) render() tea.Msg {
|
|
func (i Issue) render() tea.Msg {
|
|
|
var output string
|
|
var output string
|
|
|
// title
|
|
// title
|
|
@@ -386,6 +390,7 @@ func (i Issue) render() tea.Msg {
|
|
|
return borderStyle.Render(output)
|
|
return borderStyle.Render(output)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// keyhelp cmd for Issue widget
|
|
|
func (i Issue) keyhelp() string {
|
|
func (i Issue) keyhelp() string {
|
|
|
var output string
|
|
var output string
|
|
|
output = output + "\nj/k: down/up\t\tq: quit"
|
|
output = output + "\nj/k: down/up\t\tq: quit"
|
|
@@ -395,7 +400,7 @@ func (i Issue) keyhelp() string {
|
|
|
// -------- IssueCollection widget definitions --------------------------------
|
|
// -------- IssueCollection widget definitions --------------------------------
|
|
|
// ----------------------------------------------------------------------------
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-// Handles all render logic for IssueCollection structs.
|
|
|
|
|
|
|
+// render cmd for IssueCollection widget
|
|
|
func (ic IssueCollection) render() tea.Msg {
|
|
func (ic IssueCollection) render() tea.Msg {
|
|
|
var output string
|
|
var output string
|
|
|
var left string
|
|
var left string
|
|
@@ -418,6 +423,7 @@ func (ic IssueCollection) render() tea.Msg {
|
|
|
return output
|
|
return output
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// keyhelp cmd for IssueCollection widget
|
|
|
func (ic IssueCollection) keyhelp() string {
|
|
func (ic IssueCollection) keyhelp() string {
|
|
|
var output string
|
|
var output string
|
|
|
output = output + "\nj/k: down/up\t\tenter: select\t\tq: quit"
|
|
output = output + "\nj/k: down/up\t\tenter: select\t\tq: quit"
|
|
@@ -452,11 +458,12 @@ func (m Model) load() tea.Msg {
|
|
|
return initialCreateModel(m.Path, "lorem ipsum")
|
|
return initialCreateModel(m.Path, "lorem ipsum")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// type wrapper for create.create() result
|
|
|
type createResult Issue
|
|
type createResult Issue
|
|
|
|
|
|
|
|
// TODO implement description field in createIssue.create cmd
|
|
// TODO implement description field in createIssue.create cmd
|
|
|
|
|
|
|
|
-// A widget for creating issues
|
|
|
|
|
|
|
+// A tea.Cmd to translate create.inputs to a new Issue object
|
|
|
func (c create) create() tea.Msg {
|
|
func (c create) create() tea.Msg {
|
|
|
data := make(map[string]string)
|
|
data := make(map[string]string)
|
|
|
commaSplit := func(t string) []string {
|
|
commaSplit := func(t string) []string {
|
|
@@ -510,9 +517,10 @@ func (c create) create() tea.Msg {
|
|
|
return createResult(newIssue)
|
|
return createResult(newIssue)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// type wrapper for create.write() result
|
|
|
type writeResult any
|
|
type writeResult any
|
|
|
|
|
|
|
|
-// Wraps a cmd func, passes an initialized Issue to WriteIssue()
|
|
|
|
|
|
|
+// Wraps a tea.Cmd func, passes an initialized Issue to WriteIssue()
|
|
|
func (c create) write(issue Issue) tea.Cmd {
|
|
func (c create) write(issue Issue) tea.Cmd {
|
|
|
return func() tea.Msg {
|
|
return func() tea.Msg {
|
|
|
result, err := WriteIssue(issue, false)
|
|
result, err := WriteIssue(issue, false)
|