split scene pkg into smaller independent sub pkgs

This commit is contained in:
Samuel Recker 2023-01-16 23:48:14 +01:00
parent ba6413e9c7
commit 3e2a61615b
20 changed files with 111 additions and 105 deletions

View file

@ -7,6 +7,7 @@ import (
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -149,13 +150,13 @@ func (m apply) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch keypress := msg.String(); keypress {
case KeyControlC:
case keys.KeyControlC:
return m, tea.Quit
case KeyEscape:
case keys.KeyEscape:
m.cancelled = true
m.cancelChannel <- true
return m, nil
case KeyEnter:
case keys.KeyEnter:
if m.status.done {
if m.parent != nil {
return m.parent, m.parent.Init()

View file

@ -1,4 +1,4 @@
package scenes
package errors
const (
ErrorFailedAddMod = "failed to add mod"

View file

@ -1,4 +1,4 @@
package scenes
package installation
import (
"fmt"
@ -10,6 +10,7 @@ import (
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -78,7 +79,7 @@ func (m installation) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch keypress := msg.String(); keypress {
case KeyControlC:
case keys.KeyControlC:
return m, tea.Quit
case "q":
if m.parent != nil {
@ -91,7 +92,7 @@ func (m installation) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.parent, nil
}
return m, nil
case KeyEnter:
case keys.KeyEnter:
i, ok := m.list.SelectedItem().(utils.SimpleItem[installation])
if ok {
if i.Activate != nil {

View file

@ -1,4 +1,4 @@
package scenes
package installation
import (
"github.com/charmbracelet/bubbles/key"
@ -8,6 +8,7 @@ import (
"github.com/charmbracelet/lipgloss"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -61,7 +62,7 @@ func (m installations) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "n":
newModel := NewNewInstallation(m.root, m)
return newModel, newModel.Init()
case KeyControlC:
case keys.KeyControlC:
return m, tea.Quit
case "q":
if m.parent != nil {
@ -69,7 +70,7 @@ func (m installations) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.parent, nil
}
return m, tea.Quit
case KeyEnter:
case keys.KeyEnter:
i, ok := m.list.SelectedItem().(utils.SimpleItem[installations])
if ok {
if i.Activate != nil {

View file

@ -0,0 +1,15 @@
package installation
import tea "github.com/charmbracelet/bubbletea"
type updateInstallationList struct{}
func updateInstallationListCmd() tea.Msg {
return updateInstallationList{}
}
type updateInstallationNames struct{}
func updateInstallationNamesCmd() tea.Msg {
return updateInstallationNames{}
}

View file

@ -1,4 +1,4 @@
package scenes
package installation
import (
"fmt"
@ -19,6 +19,7 @@ import (
"github.com/sahilm/fuzzy"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -50,7 +51,7 @@ func NewNewInstallation(root components.RootModel, parent tea.Model) tea.Model {
l.KeyMap.CursorUp.SetHelp("↑", "up")
l.AdditionalShortHelpKeys = func() []key.Binding {
return []key.Binding{
key.NewBinding(key.WithKeys(KeyTab), key.WithHelp(KeyTab, "select")),
key.NewBinding(key.WithKeys(keys.KeyTab), key.WithHelp(keys.KeyTab, "select")),
}
}
@ -76,11 +77,11 @@ func (m newInstallation) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch keypress := msg.String(); keypress {
case KeyControlC:
case keys.KeyControlC:
return m, tea.Quit
case KeyEscape:
case keys.KeyEscape:
return m.parent, nil
case KeyEnter:
case keys.KeyEnter:
newInstall, err := m.root.GetGlobal().Installations.AddInstallation(m.root.GetGlobal(), m.input.Value(), m.root.GetGlobal().Profiles.SelectedProfile)
if err != nil {
errorComponent, cmd := components.NewErrorComponent(err.Error(), time.Second*5)
@ -97,7 +98,7 @@ func (m newInstallation) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
return m.parent, updateInstallationListCmd
case KeyTab:
case keys.KeyTab:
var cmd tea.Cmd
m.input, cmd = m.input.Update(msg)

View file

@ -1,4 +1,4 @@
package scenes
package keys
const (
KeyControlC = "ctrl+c"

View file

@ -11,6 +11,11 @@ import (
"github.com/spf13/viper"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/errors"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/installation"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/mods"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/profile"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -63,28 +68,28 @@ func NewMainMenu(root components.RootModel) tea.Model {
utils.SimpleItem[mainMenu]{
ItemTitle: "Installations",
Activate: func(msg tea.Msg, currentModel mainMenu) (tea.Model, tea.Cmd) {
newModel := NewInstallations(root, currentModel)
newModel := installation.NewInstallations(root, currentModel)
return newModel, newModel.Init()
},
},
utils.SimpleItem[mainMenu]{
ItemTitle: "Profiles",
Activate: func(msg tea.Msg, currentModel mainMenu) (tea.Model, tea.Cmd) {
newModel := NewProfiles(root, currentModel)
newModel := profile.NewProfiles(root, currentModel)
return newModel, newModel.Init()
},
},
utils.SimpleItem[mainMenu]{
ItemTitle: "All Mods",
Activate: func(msg tea.Msg, currentModel mainMenu) (tea.Model, tea.Cmd) {
newModel := NewMods(root, currentModel)
newModel := mods.NewMods(root, currentModel)
return newModel, newModel.Init()
},
},
utils.SimpleItem[mainMenu]{
ItemTitle: "Installed Mods",
Activate: func(msg tea.Msg, currentModel mainMenu) (tea.Model, tea.Cmd) {
newModel := NewInstalledMods(root, currentModel)
newModel := mods.NewInstalledMods(root, currentModel)
return newModel, newModel.Init()
},
},
@ -92,7 +97,7 @@ func NewMainMenu(root components.RootModel) tea.Model {
ItemTitle: "Apply Changes",
Activate: func(msg tea.Msg, currentModel mainMenu) (tea.Model, tea.Cmd) {
if err := root.GetGlobal().Save(); err != nil {
log.Error().Err(err).Msg(ErrorFailedAddMod)
log.Error().Err(err).Msg(errors.ErrorFailedAddMod)
errorComponent, cmd := components.NewErrorComponent(err.Error(), time.Second*5)
currentModel.error = errorComponent
return currentModel, cmd
@ -106,7 +111,7 @@ func NewMainMenu(root components.RootModel) tea.Model {
ItemTitle: "Save",
Activate: func(msg tea.Msg, currentModel mainMenu) (tea.Model, tea.Cmd) {
if err := root.GetGlobal().Save(); err != nil {
log.Error().Err(err).Msg(ErrorFailedAddMod)
log.Error().Err(err).Msg(errors.ErrorFailedAddMod)
errorComponent, cmd := components.NewErrorComponent(err.Error(), time.Second*5)
currentModel.error = errorComponent
return currentModel, cmd
@ -139,11 +144,11 @@ func (m mainMenu) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch keypress := msg.String(); keypress {
case KeyControlC:
case keys.KeyControlC:
return m, tea.Quit
case "q":
return m, tea.Quit
case KeyEnter:
case keys.KeyEnter:
i, ok := m.list.SelectedItem().(utils.SimpleItem[mainMenu])
if ok {
if i.Activate != nil {

View file

@ -1,11 +1,10 @@
package scenes
package mods
import (
"context"
"sort"
"time"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
@ -13,6 +12,7 @@ import (
"github.com/satisfactorymodding/ficsit-cli/ficsit"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -42,18 +42,7 @@ func NewInstalledMods(root components.RootModel, parent tea.Model) tea.Model {
l.Title = "Installed Mods"
l.Styles = utils.ListStyles
l.SetSize(l.Width(), l.Height())
l.AdditionalShortHelpKeys = func() []key.Binding {
return []key.Binding{
key.NewBinding(key.WithHelp("q", "back")),
}
}
l.AdditionalFullHelpKeys = func() []key.Binding {
return []key.Binding{
key.NewBinding(key.WithHelp("q", "back")),
}
}
l.KeyMap.Quit.SetHelp("q", "back")
m := &installedModsList{
root: root,
@ -158,8 +147,6 @@ func (m installedModsList) LoadModData() {
}
func (m installedModsList) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.list.KeyMap.Quit.SetHelp("q", "back")
switch msg := msg.(type) {
case tea.KeyMsg:
if m.list.SettingFilter() {
@ -169,7 +156,7 @@ func (m installedModsList) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
switch keypress := msg.String(); keypress {
case KeyControlC:
case keys.KeyControlC:
return m, tea.Quit
case "q":
if m.parent != nil {
@ -177,7 +164,7 @@ func (m installedModsList) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.parent, nil
}
return m, tea.Quit
case KeyEnter:
case keys.KeyEnter:
i, ok := m.list.SelectedItem().(utils.SimpleItem[installedModsList])
if ok {
return m.processActivation(i, msg)

View file

@ -1,4 +1,4 @@
package scenes
package mods
import (
"time"
@ -9,6 +9,8 @@ import (
"github.com/rs/zerolog/log"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/errors"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -69,8 +71,8 @@ func NewModMenu(root components.RootModel, parent tea.Model, mod utils.Mod) tea.
Activate: func(msg tea.Msg, currentModel modMenu) (tea.Model, tea.Cmd) {
err := root.GetCurrentProfile().AddMod(mod.Reference, ">=0.0.0")
if err != nil {
log.Error().Err(err).Msg(ErrorFailedAddMod)
cmd := currentModel.list.NewStatusMessage(ErrorFailedAddMod)
log.Error().Err(err).Msg(errors.ErrorFailedAddMod)
cmd := currentModel.list.NewStatusMessage(errors.ErrorFailedAddMod)
return currentModel, cmd
}
return currentModel.parent, nil
@ -114,7 +116,7 @@ func (m modMenu) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch keypress := msg.String(); keypress {
case KeyControlC:
case keys.KeyControlC:
return m, tea.Quit
case "q":
if m.parent != nil {
@ -122,7 +124,7 @@ func (m modMenu) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.parent, nil
}
return m, tea.Quit
case KeyEnter:
case keys.KeyEnter:
i, ok := m.list.SelectedItem().(utils.SimpleItem[modMenu])
if ok {
if i.Activate != nil {

View file

@ -1,4 +1,4 @@
package scenes
package mods
import (
"context"
@ -19,6 +19,7 @@ import (
"github.com/satisfactorymodding/ficsit-cli/ficsit"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -133,7 +134,7 @@ func (m modInfo) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch keypress := msg.String(); keypress {
case KeyControlC:
case keys.KeyControlC:
return m, tea.Quit
case "q":
if m.parent != nil {

View file

@ -1,4 +1,4 @@
package scenes
package mods
import (
"time"
@ -8,6 +8,7 @@ import (
"github.com/charmbracelet/lipgloss"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -46,11 +47,11 @@ func (m modSemver) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch keypress := msg.String(); keypress {
case KeyControlC:
case keys.KeyControlC:
return m, tea.Quit
case KeyEscape:
case keys.KeyEscape:
return m.parent, nil
case KeyEnter:
case keys.KeyEnter:
err := m.root.GetCurrentProfile().AddMod(m.mod.Reference, m.input.Value())
if err != nil {
errorComponent, cmd := components.NewErrorComponent(err.Error(), time.Second*5)

View file

@ -1,4 +1,4 @@
package scenes
package mods
import (
"time"
@ -9,6 +9,8 @@ import (
"github.com/rs/zerolog/log"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/errors"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -50,8 +52,8 @@ func NewModVersion(root components.RootModel, parent tea.Model, mod utils.Mod) t
Activate: func(msg tea.Msg, currentModel modVersionMenu) (tea.Model, tea.Cmd) {
err := root.GetCurrentProfile().AddMod(mod.Reference, ">=0.0.0")
if err != nil {
log.Error().Err(err).Msg(ErrorFailedAddMod)
cmd := currentModel.list.NewStatusMessage(ErrorFailedAddMod)
log.Error().Err(err).Msg(errors.ErrorFailedAddMod)
cmd := currentModel.list.NewStatusMessage(errors.ErrorFailedAddMod)
return currentModel, cmd
}
return currentModel.parent, nil
@ -80,7 +82,7 @@ func (m modVersionMenu) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch keypress := msg.String(); keypress {
case KeyControlC:
case keys.KeyControlC:
return m, tea.Quit
case "q":
if m.parent != nil {
@ -88,7 +90,7 @@ func (m modVersionMenu) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.parent, nil
}
return m, tea.Quit
case KeyEnter:
case keys.KeyEnter:
i, ok := m.list.SelectedItem().(utils.SimpleItem[modVersionMenu])
if ok {
if i.Activate != nil {

View file

@ -1,4 +1,4 @@
package scenes
package mods
import (
"context"
@ -17,6 +17,7 @@ import (
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/satisfactorymodding/ficsit-cli/ficsit"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -36,6 +37,8 @@ type listUpdate struct {
Done bool
}
// type keys
type modsList struct {
list list.Model
sortFieldList list.Model
@ -63,22 +66,15 @@ func NewMods(root components.RootModel, parent tea.Model) tea.Model {
l.Title = modsTitle
l.Styles = utils.ListStyles
l.SetSize(l.Width(), l.Height())
l.KeyMap.Quit.SetHelp("q", "back")
l.AdditionalShortHelpKeys = func() []key.Binding {
return []key.Binding{
key.NewBinding(key.WithHelp("q", "back")),
key.NewBinding(key.WithHelp("s", "sort")),
key.NewBinding(key.WithHelp("o", "order")),
}
}
l.AdditionalFullHelpKeys = func() []key.Binding {
return []key.Binding{
key.NewBinding(key.WithHelp("q", "back")),
key.NewBinding(key.WithHelp("s", "sort")),
key.NewBinding(key.WithHelp("o", "order")),
key.NewBinding(key.WithKeys("s"), key.WithHelp("s", "sort")),
key.NewBinding(key.WithKeys("o"), key.WithHelp("o", "order")),
}
}
l.AdditionalFullHelpKeys = l.AdditionalShortHelpKeys
sortFieldList := list.New([]list.Item{
utils.SimpleItemExtra[modsList, ficsit.ModsModsGetModsModsMod]{
@ -292,7 +288,7 @@ func (m modsList) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "o":
m.showSortOrderList = !m.showSortOrderList
return m, nil
case KeyControlC:
case keys.KeyControlC:
return m, tea.Quit
case "q":
if m.showSortFieldList {
@ -310,7 +306,7 @@ func (m modsList) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.parent, nil
}
return m, tea.Quit
case KeyEnter:
case keys.KeyEnter:
if m.showSortFieldList {
m.showSortFieldList = false
i, ok := m.sortFieldList.SelectedItem().(utils.SimpleItemExtra[modsList, ficsit.ModsModsGetModsModsMod])

View file

@ -1,4 +1,4 @@
package scenes
package mods
import (
"context"
@ -12,6 +12,7 @@ import (
"github.com/satisfactorymodding/ficsit-cli/ficsit"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -101,7 +102,7 @@ func (m selectModVersionList) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch keypress := msg.String(); keypress {
case KeyControlC:
case keys.KeyControlC:
return m, tea.Quit
case "q":
if m.parent != nil {
@ -109,7 +110,7 @@ func (m selectModVersionList) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.parent, nil
}
return m, tea.Quit
case KeyEnter:
case keys.KeyEnter:
i, ok := m.list.SelectedItem().(utils.SimpleItem[selectModVersionList])
if ok {
if i.Activate != nil {

View file

@ -1,4 +1,4 @@
package scenes
package profile
import (
tea "github.com/charmbracelet/bubbletea"
@ -15,15 +15,3 @@ type updateProfileNames struct{}
func updateProfileNamesCmd() tea.Msg {
return updateProfileNames{}
}
type updateInstallationList struct{}
func updateInstallationListCmd() tea.Msg {
return updateInstallationList{}
}
type updateInstallationNames struct{}
func updateInstallationNamesCmd() tea.Msg {
return updateInstallationNames{}
}

View file

@ -1,4 +1,4 @@
package scenes
package profile
import (
"time"
@ -10,6 +10,7 @@ import (
"github.com/charmbracelet/lipgloss"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -50,15 +51,15 @@ func NewNewProfile(root components.RootModel, parent tea.Model) tea.Model {
help: help.New(),
keys: keyMap{
Back: key.NewBinding(
key.WithKeys(KeyEscape, KeyControlC),
key.WithHelp(KeyEscape, "back"),
key.WithKeys(keys.KeyEscape, keys.KeyControlC),
key.WithHelp(keys.KeyEscape, "back"),
),
Enter: key.NewBinding(
key.WithKeys(KeyEnter),
key.WithHelp(KeyEnter, "create"),
key.WithKeys(keys.KeyEnter),
key.WithHelp(keys.KeyEnter, "create"),
),
Quit: key.NewBinding(
key.WithKeys(KeyControlC),
key.WithKeys(keys.KeyControlC),
),
},
}

View file

@ -1,4 +1,4 @@
package scenes
package profile
import (
"fmt"
@ -10,6 +10,7 @@ import (
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -90,7 +91,7 @@ func (m profile) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch keypress := msg.String(); keypress {
case KeyControlC:
case keys.KeyControlC:
return m, tea.Quit
case "q":
if m.parent != nil {
@ -103,7 +104,7 @@ func (m profile) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.parent, nil
}
return m, nil
case KeyEnter:
case keys.KeyEnter:
i, ok := m.list.SelectedItem().(utils.SimpleItem[profile])
if ok {
if i.Activate != nil {

View file

@ -1,4 +1,4 @@
package scenes
package profile
import (
"github.com/charmbracelet/bubbles/key"
@ -8,6 +8,7 @@ import (
"github.com/charmbracelet/lipgloss"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -61,7 +62,7 @@ func (m profiles) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "n":
newModel := NewNewProfile(m.root, m)
return newModel, newModel.Init()
case KeyControlC:
case keys.KeyControlC:
return m, tea.Quit
case "q":
if m.parent != nil {
@ -69,7 +70,7 @@ func (m profiles) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.parent, nil
}
return m, tea.Quit
case KeyEnter:
case keys.KeyEnter:
i, ok := m.list.SelectedItem().(utils.SimpleItem[profiles])
if ok {
if i.Activate != nil {

View file

@ -1,4 +1,4 @@
package scenes
package profile
import (
"fmt"
@ -10,6 +10,7 @@ import (
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
"github.com/satisfactorymodding/ficsit-cli/tea/scenes/keys"
"github.com/satisfactorymodding/ficsit-cli/tea/utils"
)
@ -48,11 +49,11 @@ func (m renameProfile) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch keypress := msg.String(); keypress {
case KeyControlC:
case keys.KeyControlC:
return m, tea.Quit
case KeyEscape:
case keys.KeyEscape:
return m.parent, nil
case KeyEnter:
case keys.KeyEnter:
if err := m.root.GetGlobal().Profiles.RenameProfile(m.root.GetGlobal(), m.oldName, m.input.Value()); err != nil {
errorComponent, cmd := components.NewErrorComponent(err.Error(), time.Second*5)
m.error = errorComponent