( deps commandDeps, scopeRaw string, workspaceRoot string, )
| 855 | } |
| 856 | |
| 857 | func 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 | |
| 893 | func parseWriteScope(raw string) (aghconfig.WriteScope, error) { |
| 894 | scope := aghconfig.WriteScope(strings.ToLower(strings.TrimSpace(raw))) |
no test coverage detected