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

Function LoadPadToml

internal/cli/workspace.go:89–114  ·  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

87// LoadPadToml finds and reads the nearest .pad.toml by walking up from cwd.
88// Returns nil if no .pad.toml is found (not an error).
89func LoadPadToml() (*PadToml, error) {
90 cwd, err := os.Getwd()
91 if err != nil {
92 return nil, err
93 }
94
95 dir := cwd
96 for {
97 configPath := filepath.Join(dir, ".pad.toml")
98 if _, err := os.Stat(configPath); err == nil {
99 var cfg PadToml
100 if _, err := toml.DecodeFile(configPath, &cfg); err != nil {
101 return nil, fmt.Errorf("parse %s: %w", configPath, err)
102 }
103 return &cfg, nil
104 }
105
106 parent := filepath.Dir(dir)
107 if parent == dir {
108 break
109 }
110 dir = parent
111 }
112
113 return nil, nil
114}
115
116// WriteWorkspaceLink writes a .pad.toml in the given directory.
117//

Callers 6

linkCmdFunction · 0.92
runWatchMonitorFunction · 0.92
chatSendCmdFunction · 0.92
applyPadTomlOverrideFunction · 0.92
ResolveAgentNameFunction · 0.85
ResolveAutoArmFromDiskFunction · 0.85

Calls 2

JoinMethod · 0.80
StatMethod · 0.65

Tested by

no test coverage detected