Skip to content

feat: support docs fetch user cite language#1459

Merged
ZEden0 merged 1 commit into
larksuite:mainfrom
ZEden0:feat/cli-docs-cite-user-lang-v3
Jun 16, 2026
Merged

feat: support docs fetch user cite language#1459
ZEden0 merged 1 commit into
larksuite:mainfrom
ZEden0:feat/cli-docs-cite-user-lang-v3

Conversation

@ZEden0

@ZEden0 ZEden0 commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds --lang support to docs +fetch --api-version v2 so callers can request a preferred display language for user cite names in fetched Docx content.
When --lang is omitted, the command falls back to the current profile language and omits lang entirely when no language preference is configured.

Changes

  • Add the --lang flag to the docs v2 fetch shortcut and include it in the OpenAPI fetch request body.
  • Resolve the fetch language with explicit flag value first, then profile language, then no request body field.
  • Add unit coverage for explicit language, profile language fallback, and explicit blank language behavior.
  • Document the new --lang option in the lark-doc fetch reference.

Test Plan

  • go test ./shortcuts/doc ./internal/core -run 'TestBuildFetchBody|TestDocsFetch|TestResolveConfigFromMulti_CarriesLang|TestResolveConfigFromMulti_AcceptsPlainSecret' -count=1
  • go test ./shortcuts/doc ./internal/core ./internal/credential ./cmd/config ./cmd/profile -count=1
  • git diff --check upstream/main...HEAD
  • Manual validation against a private test document:
    • docs +fetch --api-version v2 --lang en-US returns an English user cite display name.
    • docs +fetch --api-version v2 keeps the default user cite display name.
    • docs +fetch --api-version v2 --lang xx-YY succeeds and falls back to the default display name.

Related Issues

N/A

Summary by CodeRabbit

  • New Features
    • Added a --lang flag to v2 (OpenAPI) documentation fetch operations to control the language used during retrieval.
    • If --lang is set, that value is used; if not set, the operation falls back to the existing runtime configuration language; if explicitly set to an empty value, the language is omitted.
  • Bug Fixes
    • Ensured resolved multi-app configuration preserves the Lang value correctly.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4119638b-ba01-47c8-bf78-ee5f0490f25d

📥 Commits

Reviewing files that changed from the base of the PR and between 8de4da2 and bb005a8.

📒 Files selected for processing (4)
  • internal/core/config.go
  • internal/core/config_test.go
  • shortcuts/doc/docs_fetch_v2.go
  • shortcuts/doc/docs_fetch_v2_test.go
✅ Files skipped from review due to trivial changes (1)
  • internal/core/config.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • shortcuts/doc/docs_fetch_v2_test.go
  • internal/core/config_test.go

📝 Walkthrough

Walkthrough

ResolveConfigFromMulti field assignment order is corrected so Lang is set before DefaultAs in the CliConfig struct literal. A --lang flag is added to the v2 document fetch command with a resolveFetchLang helper that prefers the explicit flag value, falls back to runtime.Config.Lang, or returns empty. Tests are added for both the config propagation and the fetch body lang logic.

Changes

--lang support for lark-doc fetch

Layer / File(s) Summary
Lang field propagation in config resolution
internal/core/config.go, internal/core/config_test.go
ResolveConfigFromMulti struct literal reorders Lang before DefaultAs; TestResolveConfigFromMulti_CarriesLang verifies the Lang value is preserved through config resolution.
--lang flag, resolveFetchLang helper, and buildFetchBody integration
shortcuts/doc/docs_fetch_v2.go
Registers lang in v2FetchFlags, introduces resolveFetchLang to prefer explicit --lang or fall back to runtime.Config.Lang, and wires it into buildFetchBody to conditionally include the lang field in the fetch request.
Fetch lang flag tests and test setup
shortcuts/doc/docs_fetch_v2_test.go
Imports internal/core and registers lang string flags on test runtimes, then adds three buildFetchBody tests covering explicit flag, fallback to config, and blank-override cases.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • larksuite/cli#1132: Introduced and set AppConfig/CliConfig language fields in ResolveConfigFromMulti, which is the same function and struct this PR corrects and tests.

Suggested labels

feature

Suggested reviewers

  • GeekyMax
  • MaxHuang22

Poem

🐇 A --lang flag hops into the fray,
Config fields line up in the right display.
resolveFetchLang sniffs the best locale,
Falls back to config when flags say nothing at all.
Tests run green, the rabbit hops away! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: support docs fetch user cite language' clearly and concisely describes the primary change—adding language support to the docs fetch command for user cite names.
Description check ✅ Passed The pull request description includes all required template sections: Summary (explains motivation), Changes (lists main changes), Test Plan (with verified checkboxes), and Related Issues.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added domain/ccm PR touches the ccm domain size/M Single-domain feat or fix with limited business impact labels Jun 15, 2026
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.38%. Comparing base (297b2a2) to head (bb005a8).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1459   +/-   ##
=======================================
  Coverage   73.38%   73.38%           
=======================================
  Files         750      750           
  Lines       69355    69364    +9     
=======================================
+ Hits        50897    50906    +9     
  Misses      14709    14709           
  Partials     3749     3749           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@bb005a875bdad08af312b5de296a798b5f499efa

🧩 Skill update

npx skills add ZEden0/cli#feat/cli-docs-cite-user-lang-v3 -y -g

@ZEden0
ZEden0 force-pushed the feat/cli-docs-cite-user-lang-v3 branch from 51d0f9d to 8de4da2 Compare June 15, 2026 03:03
@ZEden0
ZEden0 force-pushed the feat/cli-docs-cite-user-lang-v3 branch from 8de4da2 to bb005a8 Compare June 16, 2026 06:06
@ZEden0
ZEden0 merged commit 64b1b3f into larksuite:main Jun 16, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/ccm PR touches the ccm domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants