Skip to content

Commit

Permalink
🎨 pull all lipgloss assignments for CI round 6
Browse files Browse the repository at this point in the history
  • Loading branch information
acidjazz committed May 20, 2024
1 parent 38e7e54 commit 8b7753a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 41 deletions.
43 changes: 7 additions & 36 deletions mvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,10 @@ func (m *Model) View() string {
status := ""
switch runner.State {
case NotStarted:
if IsCI() {
status = runner.Config.Chars.NotStarted + " " + runner.Task.Title
} else {
status = lipgloss.NewStyle().Foreground(runner.Config.Colors.Pending).Render(runner.Config.Chars.NotStarted) + " " + runner.Task.Title // Gray bullet
}
status = Color(runner.Config.Colors.Pending, runner.Config.Chars.NotStarted) + " " + runner.Task.Title // Gray bullet
case Running:
if len(runner.Children) > 0 {
if IsCI() {
status = runner.Config.Chars.ParentStarted + " " + runner.Task.Title
} else {
status = lipgloss.NewStyle().Foreground(runner.Config.Colors.ParentStarted).Render(runner.Config.Chars.ParentStarted) + " " + runner.Task.Title
}
status = Color(runner.Config.Colors.ParentStarted, runner.Config.Chars.ParentStarted) + " " + runner.Task.Title
} else {
if runner.Task.ShowProgress.Total != 0 {
percent := float64(runner.Task.ShowProgress.Current) / float64(runner.Task.ShowProgress.Total)
Expand All @@ -141,30 +133,17 @@ func (m *Model) View() string {
}
}
case Completed:
if IsCI() {
status = runner.Config.Chars.Success + " " + runner.Task.Title
} else {
status = lipgloss.NewStyle().Foreground(runner.Config.Colors.Success).Render(runner.Config.Chars.Success) + " " + runner.Task.Title // Green checkmark
}
status = Color(runner.Config.Colors.Success, runner.Config.Chars.Success) + " " + runner.Task.Title // Green checkmark
case Failed:
if IsCI() {
status = runner.Config.Chars.Failure + " " + runner.Task.Title
} else {
status = lipgloss.NewStyle().Foreground(runner.Config.Colors.Failure).Render(runner.Config.Chars.Failure) + " " + runner.Task.Title // Red 'x'

}
status = Color(runner.Config.Colors.Failure, runner.Config.Chars.Failure) + " " + runner.Task.Title // Red 'x'
}
view += lipgloss.NewStyle().Render(status) + "\n"

for _, child := range runner.Children {
status = ""
switch child.State {
case NotStarted:
if IsCI() {
status = runner.Config.Chars.NotStarted + " " + child.Task.Title
} else {
status = lipgloss.NewStyle().Foreground(child.Config.Colors.Pending).Render(runner.Config.Chars.NotStarted) + " " + child.Task.Title // Gray bullet
}
status = Color(child.Config.Colors.Pending, runner.Config.Chars.NotStarted) + " " + child.Task.Title // Gray bullet
case Running:
if child.Task.ShowProgress.Total != 0 {
percent := float64(child.Task.ShowProgress.Current) / float64(child.Task.ShowProgress.Total)
Expand All @@ -181,17 +160,9 @@ func (m *Model) View() string {
}
}
case Completed:
if IsCI() {
status = runner.Config.Chars.Success + " " + child.Task.Title
} else {
status = lipgloss.NewStyle().Foreground(child.Config.Colors.Success).Render(runner.Config.Chars.Success) + " " + child.Task.Title // Green checkmark
}
status = Color(child.Config.Colors.Success, runner.Config.Chars.Success) + " " + child.Task.Title // Green checkmark
case Failed:
if IsCI() {
status = runner.Config.Chars.Failure + " " + child.Task.Title
} else {
status = lipgloss.NewStyle().Foreground(child.Config.Colors.Failure).Render(runner.Config.Chars.Failure) + " " + child.Task.Title // Red 'x'
}
status = Color(child.Config.Colors.Failure, runner.Config.Chars.Failure) + " " + child.Task.Title // Red 'x'
}
if IsCI() {
view += " " + status + "\n"
Expand Down
6 changes: 1 addition & 5 deletions taskin.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ func (task *Task) Progress(current, total int) {

func (r *Runners) Run() error {
m := &Model{Runners: *r, Shutdown: false, ShutdownError: nil}
if IsCI() {
program = tea.NewProgram(m, tea.WithInput(nil), tea.WithoutSignals(), tea.WithoutSignalHandler())
} else {
program = tea.NewProgram(m, tea.WithInput(nil))
}
program = tea.NewProgram(m, tea.WithInput(nil))
_, err := program.Run()
if err != nil {
program.Send(TerminateWithError{Error: err})
Expand Down
10 changes: 10 additions & 0 deletions ui.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package taskin

import "github.com/charmbracelet/lipgloss"

func Color(c lipgloss.TerminalColor, r string) string {
if IsCI() {
return r
}
return lipgloss.NewStyle().Foreground(c).Render(r)
}

0 comments on commit 8b7753a

Please sign in to comment.