Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ lark-cli auth login --recommend
lark-cli calendar +agenda
```

#### Optional: Shell Completion

`lark-cli completion` is available as a regular top-level command and does not require login. Generate a completion script for the shell you use most:

```bash
# Bash
lark-cli completion bash > ~/.local/share/bash-completion/completions/lark-cli

# Zsh
mkdir -p ~/.zfunc
lark-cli completion zsh > ~/.zfunc/_lark-cli
```
Comment on lines +101 to +104
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Zsh completion setup is incomplete (same issue as Chinese README).

Missing fpath configuration. Users need to add the function path to .zshrc:

fpath=(~/.zfunc $fpath)
autoload -Uz compinit && compinit
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` around lines 101 - 104, The Zsh completion snippet is missing the
fpath and compinit configuration; update the README near the Zsh section (after
the mkdir and the generation step that writes to ~/.zfunc/_lark-cli) to instruct
users to add their function directory to fpath and initialize completions by
adding fpath=(~/.zfunc $fpath) and running autoload -Uz compinit && compinit in
their .zshrc so the generated _lark-cli file is discovered and activated.

Comment on lines +101 to +104
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Zsh setup missing fpath and compinit steps

The example writes a completion file to ~/.zfunc/_lark-cli but does not tell users to register that directory with zsh or initialize the completion system. Without adding fpath=(~/.zfunc $fpath) and autoload -Uz compinit && compinit to ~/.zshrc, the file exists on disk but zsh never loads it — completions silently fail. The same gap is present in README.zh.md (lines 101–103).

Suggested change
# Zsh
mkdir -p ~/.zfunc
lark-cli completion zsh > ~/.zfunc/_lark-cli
```
# Zsh
mkdir -p ~/.zfunc
lark-cli completion zsh > ~/.zfunc/_lark-cli
# Add to ~/.zshrc (if not already present):
# fpath=(~/.zfunc $fpath)
# autoload -Uz compinit && compinit


## Quick Start (AI Agent)

> The following steps are for AI Agents. Some steps require the user to complete actions in a browser.
Expand Down Expand Up @@ -126,6 +139,12 @@ lark-cli auth login --recommend
lark-cli auth status
```

Shell completion is also available without authentication:

```bash
lark-cli completion fish > ~/.config/fish/completions/lark-cli.fish
```

## Agent Skills

| Skill | Description |
Expand Down
19 changes: 19 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ lark-cli auth login --recommend
lark-cli calendar +agenda
```

#### 可选:Shell Completion

`lark-cli completion` 是一个普通的顶层命令,不需要先登录。可以为常用 shell 生成补全脚本:

```bash
# Bash
lark-cli completion bash > ~/.local/share/bash-completion/completions/lark-cli

# Zsh
mkdir -p ~/.zfunc
lark-cli completion zsh > ~/.zfunc/_lark-cli
```
Comment on lines +101 to +104
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Zsh completion setup is incomplete.

The Zsh instructions create the file but don't mention adding ~/.zfunc to fpath. Users would need to add this to their .zshrc:

fpath=(~/.zfunc $fpath)
autoload -Uz compinit && compinit

Consider adding this note or linking to the Zsh completion documentation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.zh.md` around lines 101 - 104, The Zsh section only creates ~/.zfunc
and the _lark-cli file but omits telling users to add that directory to their
zsh fpath and initialize completions; update the README.zh.md Zsh instructions
to tell users to add ~/.zfunc to their fpath in their .zshrc and to run the zsh
completion initialization (compinit) so the _lark-cli completion is loaded.


### 快速开始(AI Agent)

> 以下步骤面向 AI Agent,部分步骤需要用户在浏览器中配合完成。
Expand Down Expand Up @@ -126,6 +139,12 @@ lark-cli auth login --recommend
lark-cli auth status
```

Shell completion 也不依赖认证:

```bash
lark-cli completion fish > ~/.config/fish/completions/lark-cli.fish
```


## Agent Skills

Expand Down
1 change: 0 additions & 1 deletion cmd/completion/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func NewCmdCompletion(f *cmdutil.Factory) *cobra.Command {
Use: "completion <shell>",
Short: "Generate shell completion scripts",
Long: "Generate shell completion scripts for bash, zsh, fish, or powershell.",
Hidden: true,
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
23 changes: 23 additions & 0 deletions cmd/completion/completion_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
// SPDX-License-Identifier: MIT

package completion

import (
"testing"

"github.com/larksuite/cli/internal/cmdutil"
)

func TestNewCmdCompletion_IsVisibleAndAuthFree(t *testing.T) {
f, _, _, _ := cmdutil.TestFactory(t, nil)

cmd := NewCmdCompletion(f)
if cmd.Hidden {
t.Fatal("expected completion command to be visible")
}
if !cmdutil.IsAuthCheckDisabled(cmd) {
t.Fatal("expected completion command to skip auth checks")
}
}

Loading