package tools import ( "fmt" "codeberg.org/turbo-editors/turbo-core/profile" "codeberg.org/turbo-editors/turbo-core/projectfile" ) // Create writes a starter tools file for a project and returns its path. // // A project that already has one gives ErrExists and is left untouched: a file // somebody has been editing is never overwritten by a menu item. // // The file written is the profile's Templates.Tools, which is where the // commands themselves live: `go build ./...` for one editor, `cargo build` for // another. // // path, err := tools.Create(p, ".") // if errors.Is(err, tools.ErrExists) { // // already there; open it instead // } func Create(p profile.Profile, projectDir string) (string, error) { path := Path(p, projectDir) if Exists(p, projectDir) { return path, fmt.Errorf("%w: %s", ErrExists, path) } if err := projectfile.Write(path, []byte(p.Templates.Tools)); err != nil { return path, err } return path, nil }