MCPcopy Create free account
hub / github.com/celer-pkg/celer / Init

Method Init

configs/project.go:33–66  ·  view source on GitHub ↗
(ctx context.Context, projectName string)

Source from the content-addressed store, hash-verified

31}
32
33func (p *Project) Init(ctx context.Context, projectName string) error {
34 p.ctx = ctx
35
36 // Check if project name is empty.
37 projectName = strings.TrimSpace(projectName)
38 if projectName == "" {
39 return fmt.Errorf("project name is empty")
40 }
41
42 // Check if project file exists.
43 projectPath := filepath.Join(dirs.ConfProjectsDir, projectName+".toml")
44 if !fileio.PathExists(projectPath) {
45 return fmt.Errorf("%w: %s", errors.ErrProjectNotExist, projectName)
46 }
47
48 // Read conf/projects/<project_name>.toml.
49 bytes, err := os.ReadFile(projectPath)
50 if err != nil {
51 return err
52 }
53 if err := toml.Unmarshal(bytes, p); err != nil {
54 return fmt.Errorf("failed to read %s -> %w", projectPath, err)
55 }
56
57 // Default build_type.
58 if p.BuildType == "" {
59 p.BuildType = "Release"
60 }
61
62 // Set values of internal fields.
63 p.Name = projectName
64
65 return nil
66}
67
68func (p Project) Write(platformPath string, override bool) error {
69 if p.BuildType == "" {

Callers 4

cleanMethod · 0.95
showProjectTreeMethod · 0.95

Calls 1

PathExistsFunction · 0.92