MCPcopy Create free account
hub / github.com/compozy/agh / runConfigSetCommand

Function runConfigSetCommand

internal/cli/config.go:447–497  ·  view source on GitHub ↗
(
	cmd *cobra.Command,
	deps commandDeps,
	scopeRaw string,
	workspaceRoot string,
	args []string,
)

Source from the content-addressed store, hash-verified

445}
446
447func runConfigSetCommand(
448 cmd *cobra.Command,
449 deps commandDeps,
450 scopeRaw string,
451 workspaceRoot string,
452 args []string,
453) error {
454 if err := requireUnmanagedForMutation(deps, "set config values"); err != nil {
455 return err
456 }
457 homePaths, target, workspace, err := configWriteTarget(deps, scopeRaw, workspaceRoot)
458 if err != nil {
459 return err
460 }
461 if err := ensureWriteTargetParent(target); err != nil {
462 return err
463 }
464 path, kind, redacted, err := configMutationPath(args[0])
465 if err != nil {
466 return err
467 }
468 lifecycle, err := classifyConfigSetLifecycle(path)
469 if err != nil {
470 return err
471 }
472 value, err := parseConfigSetValue(kind, args[1])
473 if err != nil {
474 return err
475 }
476 liveRecord, err := maybeApplyConfigSetViaDaemon(cmd.Context(), deps, homePaths, target, path, value, redacted)
477 if err != nil {
478 return err
479 }
480 if liveRecord != nil {
481 return writeCommandOutput(cmd, configSetBundle(*liveRecord))
482 }
483 if _, err := aghconfig.EditConfigOverlay(homePaths, workspace, target, func(editor *aghconfig.OverlayEditor) error {
484 return editor.SetValue(path, value)
485 }); err != nil {
486 return err
487 }
488 record := configSetRecordForLocalWrite(path, value, target, redacted, lifecycle)
489 reloadRecord, err := maybeReloadConfigAfterLocalWrite(cmd.Context(), deps, homePaths, target, record)
490 if err != nil {
491 return err
492 }
493 if reloadRecord != nil {
494 record = *reloadRecord
495 }
496 return writeCommandOutput(cmd, configSetBundle(record))
497}
498
499func configSetRecordForLocalWrite(
500 path []string,

Callers 1

newConfigSetCommandFunction · 0.85

Calls 12

configWriteTargetFunction · 0.85
ensureWriteTargetParentFunction · 0.85
configMutationPathFunction · 0.85
parseConfigSetValueFunction · 0.85
writeCommandOutputFunction · 0.85
configSetBundleFunction · 0.85
SetValueMethod · 0.80

Tested by

no test coverage detected