ctrlret: replaced return types of controllers from tea.Cmd to tea.Msg
This dramatically cuts downs the number of closures.
This commit is contained in:
parent
931b11cd0d
commit
5b6bf1f0ae
17 changed files with 472 additions and 562 deletions
|
|
@ -32,17 +32,17 @@ func NewModel(controller *controllers.SSMController, cmdController *commandctrl.
|
|||
|
||||
cmdController.AddCommands(&commandctrl.CommandContext{
|
||||
Commands: map[string]commandctrl.Command{
|
||||
"clone": func(args []string) tea.Cmd {
|
||||
"clone": func(args []string) tea.Msg {
|
||||
if currentParam := ssmList.CurrentParameter(); currentParam != nil {
|
||||
return controller.Clone(*currentParam)
|
||||
}
|
||||
return events.SetError(errors.New("no parameter selected"))
|
||||
return events.Error(errors.New("no parameter selected"))
|
||||
},
|
||||
"delete": func(args []string) tea.Cmd {
|
||||
"delete": func(args []string) tea.Msg {
|
||||
if currentParam := ssmList.CurrentParameter(); currentParam != nil {
|
||||
return controller.DeleteParameter(*currentParam)
|
||||
}
|
||||
return events.SetError(errors.New("no parameter selected"))
|
||||
return events.Error(errors.New("no parameter selected"))
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
@ -75,7 +75,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
switch msg.String() {
|
||||
// TEMP
|
||||
case ":":
|
||||
return m, m.cmdController.Prompt()
|
||||
return m, func() tea.Msg { return m.cmdController.Prompt() }
|
||||
// END TEMP
|
||||
|
||||
case "ctrl+c", "q":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue