Complete inbox CLI implementation
This commit is contained in:
@@ -20,6 +20,7 @@ type sendOptions struct {
|
||||
kind string
|
||||
summary string
|
||||
body string
|
||||
bodyFile string
|
||||
payloadJSON string
|
||||
priority string
|
||||
}
|
||||
@@ -33,6 +34,22 @@ func newSendCmd(root *rootOptions) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
ctx := cmd.Context()
|
||||
|
||||
from := opts.from
|
||||
if from == "" {
|
||||
from = root.agent
|
||||
}
|
||||
if from == "" {
|
||||
return fmt.Errorf("from agent is required")
|
||||
}
|
||||
if opts.threadID == "" && opts.subject == "" {
|
||||
return fmt.Errorf("subject is required when creating a new thread")
|
||||
}
|
||||
|
||||
body, err := resolveBodyValue(opts.body, opts.bodyFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sqlDB, err := db.Open(ctx, root.dbPath)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -45,11 +62,11 @@ func newSendCmd(root *rootOptions) *cobra.Command {
|
||||
RunID: opts.runID,
|
||||
TaskID: opts.taskID,
|
||||
Subject: opts.subject,
|
||||
FromAgent: opts.from,
|
||||
FromAgent: from,
|
||||
ToAgent: opts.to,
|
||||
Kind: opts.kind,
|
||||
Summary: opts.summary,
|
||||
Body: opts.body,
|
||||
Body: body,
|
||||
PayloadJSON: opts.payloadJSON,
|
||||
Priority: opts.priority,
|
||||
})
|
||||
@@ -84,12 +101,11 @@ func newSendCmd(root *rootOptions) *cobra.Command {
|
||||
cmd.Flags().StringVar(&opts.kind, "kind", "task", "Initial message kind")
|
||||
cmd.Flags().StringVar(&opts.summary, "summary", "", "Short message summary")
|
||||
cmd.Flags().StringVar(&opts.body, "body", "", "Message body")
|
||||
cmd.Flags().StringVar(&opts.bodyFile, "body-file", "", "Read message body from file")
|
||||
cmd.Flags().StringVar(&opts.payloadJSON, "payload-json", "", "Structured payload JSON string")
|
||||
cmd.Flags().StringVar(&opts.priority, "priority", "normal", "Thread priority")
|
||||
|
||||
_ = cmd.MarkFlagRequired("from")
|
||||
_ = cmd.MarkFlagRequired("to")
|
||||
_ = cmd.MarkFlagRequired("subject")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user