Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💚 kill progress bars for actions #3

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions mvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"os"
)

func (r *Runners) Init() tea.Cmd {
Expand Down Expand Up @@ -32,7 +31,7 @@ func (r *Runners) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
for i := range *r {

if (*r)[i].State == Running || (*r)[i].State == NotStarted {
if os.Getenv("CI") == "" {
if !IsCI() {
newSpinner, cmd := (*r)[i].Spinner.Update(msg)
(*r)[i].Spinner = &newSpinner
cmds = append(cmds, cmd)
Expand All @@ -41,7 +40,7 @@ func (r *Runners) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

for j := range (*r)[i].Children {
if (*r)[i].Children[j].State == Running || (*r)[i].Children[j].State == NotStarted {
if os.Getenv("CI") == "" {
if !IsCI() {
newSpinner, cmd := (*r)[i].Children[j].Spinner.Update(msg)
(*r)[i].Children[j].Spinner = &newSpinner
cmds = append(cmds, cmd)
Expand Down Expand Up @@ -85,7 +84,7 @@ func (r *Runners) View() string {
var view string

// check if CI is set, if it is then don't return the view until all tasks are completed or one has failed
if os.Getenv("CI") != "" {
if IsCI() {
allDone, _ := r.checkTasksState()
if !allDone {
return ""
Expand Down
9 changes: 8 additions & 1 deletion taskin.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func NewRunner(task Task, cfg Config) Runner {

var spinr *spinner.Model

if os.Getenv("CI") == "" {
if !IsCI() {
spinnerModel := spinner.New(spinner.WithSpinner(cfg.Spinner)) // Initialize with a spinner model
spinnerModel.Style = lipgloss.NewStyle().Foreground(cfg.Colors.Spinner) // Styling spinner
spinr = &spinnerModel
Expand All @@ -36,6 +36,9 @@ func NewRunner(task Task, cfg Config) Runner {
}

func (task *Task) Progress(current, total int) {
if IsCI() {
return
}
task.ShowProgress = TaskProgress{Current: current, Total: total}
if !task.Bar.IsAnimating() {
task.Bar = progress.New(task.Config.ProgressOptions...)
Expand Down Expand Up @@ -110,3 +113,7 @@ func New(tasks Tasks, cfg Config) Runners {
}()
return runners
}

func IsCI() bool {
return os.Getenv("CI") != ""
}
Loading