Documentation
¶
Overview ¶
Package larkcli provides a subprocess bridge to the official Feishu/Lark CLI tool (lark-cli). GitCode CLI delegates Feishu operations (messaging, auth status) to lark-cli instead of reimplementing the Feishu OpenAPI and OAuth flow in Go. lark-cli keeps its own credentials in the OS keychain.
Index ¶
Constants ¶
const EnvBin = "GC_LARK_CLI_BIN"
EnvBin overrides the resolved lark-cli binary path. When set and pointing to an executable file, it takes precedence over PATH lookup.
const EnvDefaultChat = "GC_LARK_DEFAULT_CHAT_ID"
EnvDefaultChat overrides the default Feishu chat id used by notifications.
Variables ¶
ErrNotInstalled is returned when lark-cli cannot be found on PATH or via GC_LARK_CLI_BIN.
Functions ¶
func ClearDefaultChat ¶
func ClearDefaultChat() error
ClearDefaultChat removes the persisted default chat id.
func ConfigPath ¶
func ConfigPath() string
ConfigPath returns the lark config file path (~/.config/gc/lark.json or $GC_CONFIG_DIR/lark.json).
func DefaultChatID ¶
func DefaultChatID() string
DefaultChatID resolves the default Feishu chat id from, in priority order: the GC_LARK_DEFAULT_CHAT_ID environment variable, then the persisted lark.json. Returns an empty string when nothing is configured.
func EnsureInstalled ¶
func EnsureInstalled() error
EnsureInstalled returns ErrNotInstalled when lark-cli is not available.
Types ¶
type Installer ¶
type Installer struct {
// Stdout and Stderr receive installer output.
Stdout io.Writer
Stderr io.Writer
// Stdin is forwarded to the installer (interactive prompts).
Stdin io.Reader
// contains filtered or unexported fields
}
Installer runs the official lark-cli installer. It is split out so the command layer can inject a fake for tests.
type Result ¶
Result holds the captured output of a lark-cli invocation.
type RunFunc ¶
RunFunc is the injectable signature for executing lark-cli subcommands. Command packages accept a RunFunc so tests can stub out the subprocess.
var DefaultRun RunFunc = func(args []string) (*Result, error) { bin := FindLarkCLI() if bin == "" { return nil, ErrNotInstalled } return runExec(bin, args) }
DefaultRun is the production RunFunc. It resolves lark-cli via FindLarkCLI and executes it with the given args. stdin is NOT inherited (gc passes all content as explicit args; lark-cli never needs gc's stdin) and GitCode tokens (GC_TOKEN/GITCODE_TOKEN) are stripped from the child environment as defense in depth — lark-cli only needs its own keychain credentials.
Source Files
¶
- config.go
- install.go
- larkcli.go