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

Function configWriteTarget

internal/cli/config.go:857–891  ·  view source on GitHub ↗
(
	deps commandDeps,
	scopeRaw string,
	workspaceRoot string,
)

Source from the content-addressed store, hash-verified

855}
856
857func configWriteTarget(
858 deps commandDeps,
859 scopeRaw string,
860 workspaceRoot string,
861) (aghconfig.HomePaths, aghconfig.WriteTarget, string, error) {
862 scope, err := parseWriteScope(scopeRaw)
863 if err != nil {
864 return aghconfig.HomePaths{}, aghconfig.WriteTarget{}, "", err
865 }
866 workspace := ""
867 if scope == aghconfig.WriteScopeWorkspace {
868 workspace, err = resolveConfigWorkspaceRoot(deps, workspaceRoot)
869 if err != nil {
870 return aghconfig.HomePaths{}, aghconfig.WriteTarget{}, "", err
871 }
872 } else {
873 workspace, err = currentWorkingDirectory(deps)
874 if err != nil {
875 return aghconfig.HomePaths{}, aghconfig.WriteTarget{}, "", err
876 }
877 }
878 homePaths, err := deps.resolveHomeForWorkspace(workspace)
879 if err != nil {
880 return aghconfig.HomePaths{}, aghconfig.WriteTarget{}, "", err
881 }
882 writeWorkspace := ""
883 if scope == aghconfig.WriteScopeWorkspace {
884 writeWorkspace = workspace
885 }
886 target, err := aghconfig.ResolveConfigWriteTarget(homePaths, writeWorkspace, scope)
887 if err != nil {
888 return aghconfig.HomePaths{}, aghconfig.WriteTarget{}, "", err
889 }
890 return homePaths, target, writeWorkspace, nil
891}
892
893func parseWriteScope(raw string) (aghconfig.WriteScope, error) {
894 scope := aghconfig.WriteScope(strings.ToLower(strings.TrimSpace(raw)))

Callers 2

runConfigSetCommandFunction · 0.85
newConfigEditCommandFunction · 0.85

Calls 3

parseWriteScopeFunction · 0.85
currentWorkingDirectoryFunction · 0.85

Tested by

no test coverage detected