mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(cli): allow showing schedules for multiple workspaces (#10596)
* coder list: adds information about next start / stop to available columns (not default) * coder schedule: show now essentially coder list with a different set of columns * Updates cli schedule unit tests to use new dbfake Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
This commit is contained in:
co-authored by
Mathias Fredriksson
parent
177affbe4b
commit
a4f1319108
@@ -115,7 +115,7 @@ type Schedule struct {
|
||||
cronStr string
|
||||
}
|
||||
|
||||
// String serializes the schedule to its original human-friendly format.
|
||||
// String serializes the schedule to its original format.
|
||||
// The leading CRON_TZ is maintained.
|
||||
func (s Schedule) String() string {
|
||||
var sb strings.Builder
|
||||
@@ -126,6 +126,19 @@ func (s Schedule) String() string {
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
// Humanize returns a slightly more human-friendly representation of the
|
||||
// schedule.
|
||||
func (s Schedule) Humanize() string {
|
||||
var sb strings.Builder
|
||||
_, _ = sb.WriteString(s.Time())
|
||||
_, _ = sb.WriteString(" ")
|
||||
_, _ = sb.WriteString(s.DaysOfWeek())
|
||||
_, _ = sb.WriteString(" (")
|
||||
_, _ = sb.WriteString(s.Location().String())
|
||||
_, _ = sb.WriteString(")")
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
// Location returns the IANA location for the schedule.
|
||||
func (s Schedule) Location() *time.Location {
|
||||
return s.sched.Location
|
||||
|
||||
Reference in New Issue
Block a user