-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from eharris128/ech-dev-add-bubble-tea
Draft: Add Bubble Tea Dependency and TUI Command
- Loading branch information
Showing
216 changed files
with
28,629 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package tui | ||
|
||
import ( | ||
tui "github.com/mintoolkit/mint/pkg/app/master/tui" | ||
cmd "github.com/mintoolkit/mint/pkg/command" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
const ( | ||
Name = string(cmd.Tui) | ||
Usage = "Open a terminal user interface" | ||
Alias = "t" | ||
) | ||
|
||
var CLI = &cli.Command{ | ||
Name: Name, | ||
Aliases: []string{Alias}, | ||
Usage: Usage, | ||
Action: func(ctx *cli.Context) error { | ||
tui.RunTUI() | ||
return nil | ||
}, | ||
} |
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,9 @@ | ||
package init | ||
|
||
import ( | ||
"github.com/mintoolkit/mint/pkg/app/master/command/tui" | ||
) | ||
|
||
func init() { | ||
tui.RegisterCommand() | ||
} |
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,10 @@ | ||
package tui | ||
|
||
import ( | ||
"github.com/c-bata/go-prompt" | ||
) | ||
|
||
var CommandSuggestion = prompt.Suggest{ | ||
Text: Name, | ||
Description: Usage, | ||
} |
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 tui | ||
|
||
import ( | ||
"github.com/mintoolkit/mint/pkg/app/master/command" | ||
) | ||
|
||
func RegisterCommand() { | ||
command.AddCLICommand( | ||
Name, | ||
CLI, | ||
CommandSuggestion, | ||
nil) | ||
} |
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,20 @@ | ||
package tui | ||
|
||
import ( | ||
"os" | ||
|
||
log "github.com/sirupsen/logrus" | ||
|
||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/mintoolkit/mint/pkg/app/master/tui/models" | ||
) | ||
|
||
// RunTUI starts the TUI program. | ||
func RunTUI() { | ||
p := tea.NewProgram(models.InitialModel()) | ||
if _, err := p.Run(); err != nil { | ||
log.WithError(err).Error("RunTUI error") | ||
|
||
os.Exit(1) | ||
} | ||
} |
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,46 @@ | ||
package models | ||
|
||
import ( | ||
"fmt" | ||
|
||
tea "github.com/charmbracelet/bubbletea" | ||
) | ||
|
||
// Model represents the state of the TUI. | ||
type Model struct { | ||
// Add fields that represent the state of your TUI. | ||
count int | ||
} | ||
|
||
// InitialModel returns the initial state of the model. | ||
func InitialModel() Model { | ||
return Model{ | ||
count: 0, // Initialize any state variables here. | ||
} | ||
} | ||
|
||
func (m Model) Init() tea.Cmd { | ||
// Just return `nil`, which means "no I/O right now, please." | ||
return nil | ||
} | ||
|
||
// Update is called to handle user input and update the model's state. | ||
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | ||
switch msg := msg.(type) { | ||
case tea.KeyMsg: | ||
switch msg.String() { | ||
case "q", "ctrl+c": | ||
return m, tea.Quit // Quit the program. | ||
case "up": | ||
m.count++ | ||
case "down": | ||
m.count-- | ||
} | ||
} | ||
return m, nil | ||
} | ||
|
||
// View returns the view that should be displayed. | ||
func (m Model) View() string { | ||
return "Press q to quit.\n" + "Count: " + fmt.Sprint(m.count) | ||
} |
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,10 @@ | ||
package views | ||
|
||
// NOTE - Stub file. Nothing is done with these yet. | ||
func HeaderView() string { | ||
return "My TUI App\n" | ||
} | ||
|
||
func FooterView() string { | ||
return "\nPress 'q' to quit." | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.