Get 获取脚本
(ctx context.Context, scriptID string)
| 75 | |
| 76 | // Get 获取脚本 |
| 77 | func (sc *ScriptClient) Get(ctx context.Context, scriptID string) (*Script, error) { |
| 78 | if sc.client.db == nil { |
| 79 | return nil, fmt.Errorf("database not initialized") |
| 80 | } |
| 81 | |
| 82 | dbScript, err := sc.client.db.GetScript(scriptID) |
| 83 | if err != nil { |
| 84 | return nil, fmt.Errorf("failed to get script: %w", err) |
| 85 | } |
| 86 | |
| 87 | if dbScript == nil { |
| 88 | return nil, fmt.Errorf("script not found: %s", scriptID) |
| 89 | } |
| 90 | |
| 91 | // 转换为 SDK 模型 |
| 92 | return &Script{ |
| 93 | ID: dbScript.ID, |
| 94 | Name: dbScript.Name, |
| 95 | Description: dbScript.Description, |
| 96 | URL: dbScript.URL, |
| 97 | Actions: dbScript.Actions, |
| 98 | Tags: dbScript.Tags, |
| 99 | Group: dbScript.Group, |
| 100 | }, nil |
| 101 | } |
| 102 | |
| 103 | // List 列出所有脚本 |
| 104 | func (sc *ScriptClient) List(ctx context.Context) ([]*Script, error) { |
no test coverage detected