forked from riba2534/feishu-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_task.go
More file actions
62 lines (50 loc) · 1.39 KB
/
delete_task.go
File metadata and controls
62 lines (50 loc) · 1.39 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
package cmd
import (
"fmt"
"github.com/riba2534/feishu-cli/internal/client"
"github.com/riba2534/feishu-cli/internal/config"
"github.com/spf13/cobra"
)
var deleteTaskCmd = &cobra.Command{
Use: "delete <task_id>",
Short: "删除任务",
Long: `删除指定的任务。
参数:
task_id 任务 ID(必填)
--output, -o 输出格式(json)
示例:
# 删除任务
feishu-cli task delete e297ddff-06ca-4166-b917-4ce57cd3a7a0
# JSON 格式输出
feishu-cli task delete 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]
if err := client.DeleteTask(taskGuid, token); err != nil {
return err
}
output, _ := cmd.Flags().GetString("output")
if output == "json" {
if err := printJSON(map[string]any{
"success": true,
"task_id": taskGuid,
"message": "任务删除成功",
}); err != nil {
return err
}
} else {
fmt.Printf("任务删除成功!\n")
fmt.Printf(" 任务 ID: %s\n", taskGuid)
}
return nil
},
}
func init() {
taskCmd.AddCommand(deleteTaskCmd)
deleteTaskCmd.Flags().StringP("output", "o", "", "输出格式(json)")
deleteTaskCmd.Flags().String("user-access-token", "", "User Access Token(用户授权令牌)")
}