Problem
Many users have multiple Feishu/Lark accounts (e.g., enterprise + personal), but lark-cli currently only supports one active app at a time.
The root cause is two-fold:
RequireConfig() hardcodes Apps[0] — only the first app in the config array is ever used
config init --new calls cleanupOldConfig() — which explicitly removes all other apps' keychain entries
This means there's no way to switch between accounts without re-running config init and auth login each time.
Current workaround
The undocumented LARKSUITE_CLI_CONFIG_DIR env var allows completely isolated config directories:
# Create isolated config dirs
mkdir ~/.lark-cli-work ~/.lark-cli-personal
# Set up each account independently
LARKSUITE_CLI_CONFIG_DIR=~/.lark-cli-work lark-cli config init --new
LARKSUITE_CLI_CONFIG_DIR=~/.lark-cli-work lark-cli auth login --recommend
LARKSUITE_CLI_CONFIG_DIR=~/.lark-cli-personal lark-cli config init --new
LARKSUITE_CLI_CONFIG_DIR=~/.lark-cli-personal lark-cli auth login --recommend
Then use wrapper scripts:
# ~/.local/bin/lark-work
#!/bin/bash
export LARKSUITE_CLI_CONFIG_DIR="$HOME/.lark-cli-work"
exec lark-cli "$@"
# ~/.local/bin/lark-personal
#!/bin/bash
export LARKSUITE_CLI_CONFIG_DIR="$HOME/.lark-cli-personal"
exec lark-cli "$@"
This works, but it's fragile and not discoverable.
Proposal
A native profile system, similar to AWS CLI's --profile:
# Setup
lark-cli config init --profile work
lark-cli config init --profile personal
# Auth
lark-cli auth login --profile work --recommend
lark-cli auth login --profile personal --recommend
# Usage
lark-cli docs +fetch --doc "..." --profile work
lark-cli calendar +agenda --profile personal
# Set default profile
lark-cli config default-profile work
Implementation scope (rough estimate)
internal/core/config.go: RequireConfig() to accept a profile parameter instead of hardcoding Apps[0]
cmd/config/init.go: cleanupOldConfig() should not wipe other profiles' keychain entries
internal/cmdutil/factory.go: Add --profile as a global flag with env var LARKSUITE_CLI_PROFILE
- Config format: Each profile maps to an entry in the existing
apps[] array, with a profile name field
The apps[] array structure already exists in config.json — it just needs to be properly exposed.
Environment
- lark-cli v1.0.0
- Windows 11 / macOS (both affected)
Happy to submit a PR if this direction looks good.
Problem
Many users have multiple Feishu/Lark accounts (e.g., enterprise + personal), but lark-cli currently only supports one active app at a time.
The root cause is two-fold:
RequireConfig()hardcodesApps[0]— only the first app in the config array is ever usedconfig init --newcallscleanupOldConfig()— which explicitly removes all other apps' keychain entriesThis means there's no way to switch between accounts without re-running
config initandauth logineach time.Current workaround
The undocumented
LARKSUITE_CLI_CONFIG_DIRenv var allows completely isolated config directories:Then use wrapper scripts:
This works, but it's fragile and not discoverable.
Proposal
A native profile system, similar to AWS CLI's
--profile:Implementation scope (rough estimate)
internal/core/config.go:RequireConfig()to accept a profile parameter instead of hardcodingApps[0]cmd/config/init.go:cleanupOldConfig()should not wipe other profiles' keychain entriesinternal/cmdutil/factory.go: Add--profileas a global flag with env varLARKSUITE_CLI_PROFILEapps[]array, with aprofilename fieldThe
apps[]array structure already exists in config.json — it just needs to be properly exposed.Environment
Happy to submit a PR if this direction looks good.