Skip to content

Feature Request: Multi-account / Profile support #29

Description

@Aojianlong

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:

  1. RequireConfig() hardcodes Apps[0] — only the first app in the config array is ever used
  2. 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)

  1. internal/core/config.go: RequireConfig() to accept a profile parameter instead of hardcoding Apps[0]
  2. cmd/config/init.go: cleanupOldConfig() should not wipe other profiles' keychain entries
  3. internal/cmdutil/factory.go: Add --profile as a global flag with env var LARKSUITE_CLI_PROFILE
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    domain/authAuthentication subsystemdomain/calendarPR touches the calendar domaindomain/coreCLI framework and core librariesdomain/docDocs domainenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions