-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
200 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,8 @@ tmp/ | |
!.env.example | ||
|
||
# Project build | ||
scc | ||
backend | ||
tui | ||
|
||
.data/ | ||
/public/ | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/zeusWPI/scc/internal/pkg/db" | ||
"github.com/zeusWPI/scc/internal/pkg/spotify" | ||
) | ||
|
||
// Spotify starts the Spotify integration | ||
func Spotify(db *db.DB) (*spotify.Spotify, error) { | ||
spotify, err := spotify.New(db) | ||
|
||
return spotify, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Package cmd provides all the commands to start parts of the application | ||
package cmd | ||
|
||
import ( | ||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/zeusWPI/scc/internal/pkg/db" | ||
tui "github.com/zeusWPI/scc/ui" | ||
) | ||
|
||
// TUI starts the terminal user interface | ||
func TUI(db *db.DB) *tea.Program { | ||
tui := tui.New(db) | ||
|
||
program := tea.NewProgram(tui) | ||
|
||
return program | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Package tui provides utilities for working with the terminal. | ||
package tui | ||
|
||
import ( | ||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/zeusWPI/scc/internal/pkg/db" | ||
"github.com/zeusWPI/scc/ui/views" | ||
"go.uber.org/zap" | ||
) | ||
|
||
// TUI represent a terminal instance | ||
type TUI struct { | ||
db *db.DB | ||
tap tea.Model | ||
} | ||
|
||
// New creates a new tty instance | ||
func New(db *db.DB) *TUI { | ||
return &TUI{ | ||
db: db, | ||
tap: views.NewTapModel(db), | ||
} | ||
} | ||
|
||
// Init initializes the tty | ||
func (t *TUI) Init() tea.Cmd { | ||
return tea.Batch(tea.EnterAltScreen, t.tap.Init()) | ||
} | ||
|
||
// Update updates the tty | ||
func (t *TUI) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | ||
var cmds []tea.Cmd | ||
|
||
tapModel, tapCmd := t.tap.Update(msg) | ||
if tapCmd != nil { | ||
cmds = append(cmds, tapCmd) | ||
} | ||
t.tap = tapModel | ||
|
||
switch msg := msg.(type) { | ||
case tea.KeyMsg: | ||
switch msg.Type { | ||
case tea.KeyCtrlC: | ||
zap.S().Info("Exiting") | ||
cmds = append(cmds, tea.ExitAltScreen) | ||
cmds = append(cmds, tea.Quit) | ||
} | ||
} | ||
|
||
return t, tea.Batch(cmds...) | ||
} | ||
|
||
// View returns the tty view | ||
func (t *TUI) View() string { | ||
return t.tap.View() | ||
} |