WriteWorkspaceLink writes a .pad.toml in the given directory. serverURL is the base URL of the Pad server hosting this workspace. Pass the empty string for local-mode workspaces; pass cfg.BaseURL() (or equivalently cfg.URL) for any non-local mode (remote, cloud) so that the directory targets the ri
(dir, slug, serverURL string)
| 92 | // directory targets the right server even when the user's global config |
| 93 | // points at a different one. See BUG-1535. |
| 94 | func WriteWorkspaceLink(dir, slug, serverURL string) error { |
| 95 | path := filepath.Join(dir, ".pad.toml") |
| 96 | f, err := os.Create(path) |
| 97 | if err != nil { |
| 98 | return err |
| 99 | } |
| 100 | defer f.Close() |
| 101 | return toml.NewEncoder(f).Encode(PadToml{Workspace: slug, URL: serverURL}) |
| 102 | } |