MCPcopy Create free account
hub / github.com/diillson/chatcli / handleUpdate

Method handleUpdate

cli/context_handler.go:214–294  ·  view source on GitHub ↗

handleUpdate atualiza um contexto existente

(ctx context.Context, args []string)

Source from the content-addressed store, hash-verified

212
213// handleUpdate atualiza um contexto existente
214func (h *ContextHandler) handleUpdate(ctx context.Context, args []string) error {
215 if len(args) < 1 {
216 return fmt.Errorf("%s", i18n.T("context.update.usage"))
217 }
218
219 name := args[0]
220 var description, modeStr string
221 var paths []string
222 var tags []string
223
224 // Parser similar ao create
225 i := 1
226 for i < len(args) {
227 arg := args[i]
228
229 switch {
230 case arg == "--mode" || arg == "-m":
231 if i+1 >= len(args) {
232 return fmt.Errorf("%s", i18n.T("context.create.error.mode_required"))
233 }
234 i++
235 modeStr = args[i]
236 i++
237
238 case arg == "--description" || arg == "--desc" || arg == "-d":
239 if i+1 >= len(args) {
240 return fmt.Errorf("%s", i18n.T("context.create.error.description_required"))
241 }
242 i++
243 description = args[i]
244 i++
245
246 case arg == "--tags" || arg == "-t":
247 if i+1 >= len(args) {
248 return fmt.Errorf("%s", i18n.T("context.create.error.tags_required"))
249 }
250 i++
251 tags = strings.Split(args[i], ",")
252 i++
253
254 case strings.HasPrefix(arg, "--") || strings.HasPrefix(arg, "-"):
255 return fmt.Errorf("%s", i18n.T("context.io.error.unknown_flag", arg))
256
257 default:
258 paths = append(paths, arg)
259 i++
260 }
261 }
262
263 // Validar modo se fornecido
264 mode := ctxmgr.ProcessingMode("")
265 if modeStr != "" {
266 mode = ctxmgr.ProcessingMode(strings.ToLower(modeStr))
267 validModes := map[ctxmgr.ProcessingMode]bool{
268 ctxmgr.ModeFull: true,
269 ctxmgr.ModeSummary: true,
270 ctxmgr.ModeChunked: true,
271 ctxmgr.ModeSmart: true,

Callers 1

HandleContextCommandMethod · 0.95

Calls 6

printContextInfoMethod · 0.95
TFunction · 0.92
ProcessingModeTypeAlias · 0.92
colorizeFunction · 0.85
ErrorfMethod · 0.80
UpdateContextMethod · 0.80

Tested by

no test coverage detected