Skip to content

Commit

Permalink
Add sorting options
Browse files Browse the repository at this point in the history
  • Loading branch information
Vilsol committed Dec 4, 2021
1 parent 1b1b8c1 commit 072e6d9
Show file tree
Hide file tree
Showing 12 changed files with 1,009 additions and 78 deletions.
7 changes: 6 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ archives:
name_template: "{{ .Binary }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}"

nfpms:
- formats:
- vendor: Satisfactory Modding
homepage: https://ficsit.app/
maintainer: Satisfactory Modding Team <[email protected]>
description: CLI tool for Ficsit (Satisfactory Modding)
license: GNU General Public License v3.0
formats:
- apk
- deb
- rpm
Expand Down
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions ficsit/queries/mods.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ query Mods ($filter: ModFilter) {
id
name
mod_reference
last_version_date
created_at
}
}
}
25 changes: 25 additions & 0 deletions ficsit/utils/json.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package utils

import (
"bytes"
"time"
)

//goland:noinspection GoUnusedExportedFunction
func UnmarshalDateTime(b []byte, v *time.Time) error {
trimmed := bytes.Trim(b, "\"")

if len(trimmed) == 0 {
*v = time.Unix(0, 0)
return nil
}

parsed, err := time.Parse(time.RFC3339, string(trimmed))
if err != nil {
return err
}

*v = parsed

return nil
}
3 changes: 2 additions & 1 deletion genqlient.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ bindings:
SMLVersionID:
type: string
Date:
type: time.Time
type: time.Time
unmarshaler: github.com/satisfactorymodding/ficsit-cli/ficsit/utils.UnmarshalDateTime
6 changes: 3 additions & 3 deletions tea/scenes/exit_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewExitMenu(root components.RootModel) tea.Model {

items := []list.Item{
utils.SimpleItem{
Title: "Exit Saving Changes",
ItemTitle: "Exit Saving Changes",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
if err := root.GetGlobal().Save(); err != nil {
panic(err) // TODO
Expand All @@ -33,14 +33,14 @@ func NewExitMenu(root components.RootModel) tea.Model {
},
},
utils.SimpleItem{
Title: "Exit Discarding Changes",
ItemTitle: "Exit Discarding Changes",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
return currentModel, tea.Quit
},
},
}

model.list = list.NewModel(items, utils.ItemDelegate{}, root.Size().Width, root.Size().Height-root.Height())
model.list = list.NewModel(items, utils.NewItemDelegate(), root.Size().Width, root.Size().Height-root.Height())
model.list.SetShowStatusBar(false)
model.list.SetFilteringEnabled(false)
model.list.Title = "Save Changes?"
Expand Down
14 changes: 7 additions & 7 deletions tea/scenes/main_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,35 @@ func NewMainMenu(root components.RootModel) tea.Model {

items := []list.Item{
utils.SimpleItem{
Title: "Installations",
ItemTitle: "Installations",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
newModel := NewInstallations(root, currentModel)
return newModel, newModel.Init()
},
},
utils.SimpleItem{
Title: "Profiles",
ItemTitle: "Profiles",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
newModel := NewProfiles(root, currentModel)
return newModel, newModel.Init()
},
},
utils.SimpleItem{
Title: "Mods",
ItemTitle: "Mods",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
newModel := NewMods(root, currentModel)
return newModel, newModel.Init()
},
},
utils.SimpleItem{
Title: "Apply Changes",
ItemTitle: "Apply Changes",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
// TODO Apply changes to all changed profiles
return nil, nil
},
},
utils.SimpleItem{
Title: "Save",
ItemTitle: "Save",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
if err := root.GetGlobal().Save(); err != nil {
panic(err) // TODO Handle Error
Expand All @@ -61,15 +61,15 @@ func NewMainMenu(root components.RootModel) tea.Model {
},
},
utils.SimpleItem{
Title: "Exit",
ItemTitle: "Exit",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
newModel := NewExitMenu(root)
return newModel, newModel.Init()
},
},
}

model.list = list.NewModel(items, utils.ItemDelegate{}, root.Size().Width, root.Size().Height-root.Height())
model.list = list.NewModel(items, utils.NewItemDelegate(), root.Size().Width, root.Size().Height-root.Height())
model.list.SetShowStatusBar(false)
model.list.SetFilteringEnabled(false)
model.list.Title = "Main Menu"
Expand Down
12 changes: 6 additions & 6 deletions tea/scenes/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ func NewModMenu(root components.RootModel, parent tea.Model, mod utils.Mod) tea.
if root.GetCurrentProfile().HasMod(mod.Reference) {
items = []list.Item{
utils.SimpleItem{
Title: "Remove Mod",
ItemTitle: "Remove Mod",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
root.GetCurrentProfile().RemoveMod(mod.Reference)
return currentModel.(modMenu).parent, nil
},
},
utils.SimpleItem{
Title: "Change Version",
ItemTitle: "Change Version",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
newModel := NewModVersion(root, currentModel.(modMenu).parent, mod)
return newModel, newModel.Init()
Expand All @@ -45,7 +45,7 @@ func NewModMenu(root components.RootModel, parent tea.Model, mod utils.Mod) tea.
} else {
items = []list.Item{
utils.SimpleItem{
Title: "Install Mod",
ItemTitle: "Install Mod",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
err := root.GetCurrentProfile().AddMod(mod.Reference, ">=0.0.0")
if err != nil {
Expand All @@ -55,7 +55,7 @@ func NewModMenu(root components.RootModel, parent tea.Model, mod utils.Mod) tea.
},
},
utils.SimpleItem{
Title: "Install Mod with specific version",
ItemTitle: "Install Mod with specific version",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
newModel := NewModVersion(root, currentModel.(modMenu).parent, mod)
return newModel, newModel.Init()
Expand All @@ -65,14 +65,14 @@ func NewModMenu(root components.RootModel, parent tea.Model, mod utils.Mod) tea.
}

items = append(items, utils.SimpleItem{
Title: "View Mod info",
ItemTitle: "View Mod info",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
newModel := NewModInfo(root, currentModel, mod)
return newModel, newModel.Init()
},
})

model.list = list.NewModel(items, utils.ItemDelegate{}, root.Size().Width, root.Size().Height-root.Height())
model.list = list.NewModel(items, utils.NewItemDelegate(), root.Size().Width, root.Size().Height-root.Height())
model.list.SetShowStatusBar(false)
model.list.SetFilteringEnabled(false)
model.list.Title = mod.Name
Expand Down
8 changes: 4 additions & 4 deletions tea/scenes/mod_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ func NewModVersion(root components.RootModel, parent tea.Model, mod utils.Mod) t

items := []list.Item{
utils.SimpleItem{
Title: "Select Version",
ItemTitle: "Select Version",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
newModel := NewModVersionList(root, currentModel.(modMenu).parent, mod)
return newModel, newModel.Init()
},
},
utils.SimpleItem{
Title: "Enter Custom SemVer",
ItemTitle: "Enter Custom SemVer",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
newModel := NewModSemver(root, currentModel.(modMenu).parent, mod)
return newModel, newModel.Init()
Expand All @@ -44,7 +44,7 @@ func NewModVersion(root components.RootModel, parent tea.Model, mod utils.Mod) t
if root.GetCurrentProfile().HasMod(mod.Reference) {
items = append([]list.Item{
utils.SimpleItem{
Title: "Latest",
ItemTitle: "Latest",
Activate: func(msg tea.Msg, currentModel tea.Model) (tea.Model, tea.Cmd) {
err := root.GetCurrentProfile().AddMod(mod.Reference, ">=0.0.0")
if err != nil {
Expand All @@ -56,7 +56,7 @@ func NewModVersion(root components.RootModel, parent tea.Model, mod utils.Mod) t
}, items...)
}

model.list = list.NewModel(items, utils.ItemDelegate{}, root.Size().Width, root.Size().Height-root.Height())
model.list = list.NewModel(items, utils.NewItemDelegate(), root.Size().Width, root.Size().Height-root.Height())
model.list.SetShowStatusBar(false)
model.list.SetFilteringEnabled(false)
model.list.Title = mod.Name
Expand Down
Loading

0 comments on commit 072e6d9

Please sign in to comment.