fix(cron): show all payload fields in cron list output

The list command previously showed only name, ID, schedule, status, and
next run time. Channel, recipient, deliver mode, and message/command were
hidden, making it impossible to tell from the CLI what a job would do or
which agent would handle it.

All payload fields are now displayed. Messages longer than 80 characters
are truncated with an ellipsis. Jobs with a command show the command
instead of a message.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Eric Jacksch 2026-03-20 01:31:38 -04:00
parent 3aafbca673
commit 99715e4de8

View file

@ -7,6 +7,8 @@ import (
"github.com/sipeed/picoclaw/pkg/cron"
)
const maxMessageDisplay = 80
func cronListCmd(storePath string) {
cs := cron.NewCronService(storePath, nil)
jobs := cs.ListJobs(true) // Show all jobs, including disabled
@ -41,8 +43,20 @@ func cronListCmd(storePath string) {
fmt.Printf(" %s (%s)\n", job.Name, job.ID)
fmt.Printf(" Schedule: %s\n", schedule)
fmt.Printf(" Status: %s\n", status)
fmt.Printf(" Status: %s\n", status)
fmt.Printf(" Next run: %s\n", nextRun)
fmt.Printf(" Channel: %s\n", job.Payload.Channel)
fmt.Printf(" To: %s\n", job.Payload.To)
fmt.Printf(" Deliver: %v\n", job.Payload.Deliver)
if job.Payload.Command != "" {
fmt.Printf(" Command: %s\n", job.Payload.Command)
} else {
msg := job.Payload.Message
if len(msg) > maxMessageDisplay {
msg = msg[:maxMessageDisplay] + "..."
}
fmt.Printf(" Message: %s\n", msg)
}
}
}