MCPcopy Index your code
hub / github.com/larksuite/cli / GetBaseConfigDir

Function GetBaseConfigDir

internal/core/workspace.go:132–147  ·  view source on GitHub ↗

GetBaseConfigDir returns the root config directory, ignoring workspace. Priority: LARKSUITE_CLI_CONFIG_DIR env → ~/.lark-cli. If the home directory cannot be determined and no override is set, a warning is written to stderr and the path falls back to a relative ".lark-cli" — callers will then see an

()

Source from the content-addressed store, hash-verified

130// ".lark-cli" — callers will then see an explicit I/O error at first use
131// instead of a silent misconfiguration.
132func GetBaseConfigDir() string {
133 if dir := os.Getenv("LARKSUITE_CLI_CONFIG_DIR"); dir != "" {
134 return dir
135 }
136 home, err := vfs.UserHomeDir()
137 if err != nil || home == "" {
138 // Fall back to a relative ".lark-cli" so the first I/O operation
139 // surfaces a clear "no such file or directory" error. We cannot
140 // emit a stderr warning here — this package has no IOStreams in
141 // scope, and direct writes to os.Stderr violate the IOStreams
142 // injection boundary (enforced by lint). Users who hit this path
143 // should set LARKSUITE_CLI_CONFIG_DIR explicitly.
144 home = ""
145 }
146 return filepath.Join(home, ".lark-cli")
147}
148
149// GetRuntimeDir returns the workspace-aware config directory.
150// - WorkspaceLocal → GetBaseConfigDir() (unchanged, backward-compatible)

Callers 4

statePathFunction · 0.92
WriteStateFunction · 0.92
userPolicyPathFunction · 0.92
GetRuntimeDirFunction · 0.85

Calls 1

UserHomeDirFunction · 0.92

Tested by

no test coverage detected