forked from riba2534/feishu-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplete_task.go
More file actions
63 lines (51 loc) · 1.47 KB
/
complete_task.go
File metadata and controls
63 lines (51 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package cmd
import (
"fmt"
"github.com/riba2534/feishu-cli/internal/client"
"github.com/riba2534/feishu-cli/internal/config"
"github.com/spf13/cobra"
)
var completeTaskCmd = &cobra.Command{
Use: "complete <task_id>",
Short: "完成任务",
Long: `将指定的任务标记为已完成。
参数:
task_id 任务 ID(必填)
--output, -o 输出格式(json)
示例:
# 完成任务
feishu-cli task complete e297ddff-06ca-4166-b917-4ce57cd3a7a0
# JSON 格式输出
feishu-cli task complete e297ddff-06ca-4166-b917-4ce57cd3a7a0 --output json`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if err := config.Validate(); err != nil {
return err
}
token := resolveOptionalUserToken(cmd)
taskGuid := args[0]
task, err := client.CompleteTask(taskGuid, token)
if err != nil {
return err
}
output, _ := cmd.Flags().GetString("output")
if output == "json" {
if err := printJSON(task); err != nil {
return err
}
} else {
fmt.Printf("任务已完成!\n")
fmt.Printf(" 任务 ID: %s\n", task.Guid)
fmt.Printf(" 标题: %s\n", task.Summary)
if task.CompletedAt != "" {
fmt.Printf(" 完成时间: %s\n", task.CompletedAt)
}
}
return nil
},
}
func init() {
taskCmd.AddCommand(completeTaskCmd)
completeTaskCmd.Flags().StringP("output", "o", "", "输出格式(json)")
completeTaskCmd.Flags().String("user-access-token", "", "User Access Token(用户授权令牌)")
}