github.com/benchkram/bob@v0.0.0-20240314204020-b7a57f2f9be9/bob/playbook/state.go (about)

     1  package playbook
     2  
     3  import "github.com/logrusorgru/aurora"
     4  
     5  type State string
     6  
     7  // Summary state indicators.
     8  // The nbsp are intended to align on the cli.
     9  func (s *State) Summary() string {
    10  	switch *s {
    11  	case StatePending:
    12  		return "⌛       "
    13  	case StateCompleted:
    14  		return aurora.Green("✔").Bold().String() + "       "
    15  	case StateNoRebuildRequired:
    16  		return aurora.Green("cached").String() + "  "
    17  	case StateFailed:
    18  		return aurora.Red("failed").String() + "  "
    19  	case StateCanceled:
    20  		return aurora.Faint("canceled").String()
    21  	case StateQueued:
    22  		return aurora.Faint("queued").String()
    23  	default:
    24  		return ""
    25  	}
    26  }
    27  
    28  func (s *State) Short() string {
    29  	switch *s {
    30  	case StatePending:
    31  		return "pending"
    32  	case StateCompleted:
    33  		return "done"
    34  	case StateNoRebuildRequired:
    35  		return "cached"
    36  	case StateFailed:
    37  		return "failed"
    38  	case StateCanceled:
    39  		return "canceled"
    40  	case StateQueued:
    41  		return "queued"
    42  	default:
    43  		return ""
    44  	}
    45  }
    46  
    47  const (
    48  	StatePending           State = "PENDING"
    49  	StateCompleted         State = "COMPLETED"
    50  	StateNoRebuildRequired State = "CACHED"
    51  	StateFailed            State = "FAILED"
    52  	StateRunning           State = "RUNNING"
    53  	StateCanceled          State = "CANCELED"
    54  	StateQueued            State = "QUEUED"
    55  )