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

Function newConfigEditCommand

internal/cli/config.go:716–765  ·  view source on GitHub ↗
(deps commandDeps)

Source from the content-addressed store, hash-verified

714}
715
716func newConfigEditCommand(deps commandDeps) *cobra.Command {
717 var (
718 scopeRaw string
719 workspaceRoot string
720 )
721 cmd := &cobra.Command{
722 Use: configEditKey,
723 Short: "Open the selected config overlay in $VISUAL or $EDITOR",
724 Args: cobra.NoArgs,
725 RunE: func(cmd *cobra.Command, _ []string) error {
726 if err := requireUnmanagedForMutation(deps, "edit config"); err != nil {
727 return err
728 }
729 homePaths, target, workspace, err := configWriteTarget(deps, scopeRaw, workspaceRoot)
730 if err != nil {
731 return err
732 }
733 if err := ensureWriteTargetParent(target); err != nil {
734 return err
735 }
736 if err := ensureEditableConfigFile(target.Path()); err != nil {
737 return err
738 }
739 if err := runConfigEditor(cmd, deps, target.Path()); err != nil {
740 return err
741 }
742 loadOptions := []aghconfig.LoadOption{}
743 if workspace != "" {
744 loadOptions = append(loadOptions, aghconfig.WithWorkspaceRoot(workspace))
745 }
746 if _, err := aghconfig.LoadForHome(homePaths, loadOptions...); err != nil {
747 return fmt.Errorf("cli: edited config failed validation: %w", err)
748 }
749 return writeCommandOutput(cmd, configSetBundle(configSetRecord{
750 Path: "",
751 Value: "edited",
752 Scope: string(target.Scope()),
753 Target: target.Path(),
754 Lifecycle: string(contract.SettingsApplyLifecycleRestartRequired),
755 NextAction: string(contract.SettingsApplyNextActionRestartDaemon),
756 RestartRequired: true,
757 RestartScope: configDaemonKey,
758 }))
759 },
760 }
761 cmd.Flags().
762 StringVar(&scopeRaw, configScopeKey, string(aghconfig.WriteScopeGlobal), "Edit scope: global or workspace")
763 cmd.Flags().StringVar(&workspaceRoot, "workspace", "", "Workspace root for workspace-scoped edits")
764 return cmd
765}
766
767func newConfigReloadCommand(deps commandDeps) *cobra.Command {
768 cmd := &cobra.Command{

Callers 1

newConfigCommandFunction · 0.85

Calls 10

configWriteTargetFunction · 0.85
ensureWriteTargetParentFunction · 0.85
ensureEditableConfigFileFunction · 0.85
runConfigEditorFunction · 0.85
appendFunction · 0.85
writeCommandOutputFunction · 0.85
configSetBundleFunction · 0.85
ScopeMethod · 0.80
PathMethod · 0.65

Tested by

no test coverage detected