Load 加载命令定义
(ctx context.Context, commandName string)
| 32 | |
| 33 | // Load 加载命令定义 |
| 34 | func (cl *CommandLoader) Load(ctx context.Context, commandName string) (*CommandDefinition, error) { |
| 35 | // 读取 {commandName}.md |
| 36 | path := filepath.Join(cl.baseDir, commandName+".md") |
| 37 | |
| 38 | content, err := cl.fs.Read(ctx, path) |
| 39 | if err != nil { |
| 40 | return nil, fmt.Errorf("read command file: %w", err) |
| 41 | } |
| 42 | |
| 43 | return cl.parse(commandName, content) |
| 44 | } |
| 45 | |
| 46 | // parse 解析命令文件 |
| 47 | func (cl *CommandLoader) parse(name, content string) (*CommandDefinition, error) { |