MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / LoadPadToml

Function LoadPadToml

internal/cli/workspace.go:60–85  ·  view source on GitHub ↗

LoadPadToml finds and reads the nearest .pad.toml by walking up from cwd. Returns nil if no .pad.toml is found (not an error).

()

Source from the content-addressed store, hash-verified

58// LoadPadToml finds and reads the nearest .pad.toml by walking up from cwd.
59// Returns nil if no .pad.toml is found (not an error).
60func LoadPadToml() (*PadToml, error) {
61 cwd, err := os.Getwd()
62 if err != nil {
63 return nil, err
64 }
65
66 dir := cwd
67 for {
68 configPath := filepath.Join(dir, ".pad.toml")
69 if _, err := os.Stat(configPath); err == nil {
70 var cfg PadToml
71 if _, err := toml.DecodeFile(configPath, &cfg); err != nil {
72 return nil, fmt.Errorf("parse %s: %w", configPath, err)
73 }
74 return &cfg, nil
75 }
76
77 parent := filepath.Dir(dir)
78 if parent == dir {
79 break
80 }
81 dir = parent
82 }
83
84 return nil, nil
85}
86
87// WriteWorkspaceLink writes a .pad.toml in the given directory.
88//

Callers 2

applyPadTomlOverrideFunction · 0.92
NewClientFromURLFunction · 0.85

Calls 2

JoinMethod · 0.80
StatMethod · 0.65

Tested by

no test coverage detected