mirror of
https://github.com/larksuite/cli.git
synced 2026-07-07 00:55:53 +08:00
fix(sheets): make --max-chars the single read cap for +cells-get / +csv-get
Drop --cell-limit (+cells-get) and --max-rows (+csv-get) from the CLI surface and pin the underlying tool's cell_limit / max_rows to a very large sentinel so the tool's own defaults never truncate before --max-chars. --max-chars stays the only knob (default 200000, unchanged). - lark_sheet_read_data.go: add unboundedReadLimit (1e9); cellsGetInput pins cell_limit, csvGetInput pins max_rows; --max-chars still passed through - data/flag-defs.json: synced from spec (drops the two flags) - tests: spot-check moved to --max-chars; dry-run wantInput asserts cell_limit / max_rows are pinned high Mirrors sheet-skill-spec (Base flag records removed). go build ./... + go test ./shortcuts/sheets/ green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1196,15 +1196,6 @@
|
|||||||
"data_validation"
|
"data_validation"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "cell-limit",
|
|
||||||
"kind": "own",
|
|
||||||
"type": "int",
|
|
||||||
"required": "optional",
|
|
||||||
"desc": "Safety cap; default 5000",
|
|
||||||
"default": "5000",
|
|
||||||
"hidden": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "max-chars",
|
"name": "max-chars",
|
||||||
"kind": "own",
|
"kind": "own",
|
||||||
@@ -1314,15 +1305,6 @@
|
|||||||
"formula"
|
"formula"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "max-rows",
|
|
||||||
"kind": "own",
|
|
||||||
"type": "int",
|
|
||||||
"required": "optional",
|
|
||||||
"desc": "Safety cap; default 100000",
|
|
||||||
"default": "100000",
|
|
||||||
"hidden": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "max-chars",
|
"name": "max-chars",
|
||||||
"kind": "own",
|
"kind": "own",
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ func TestFlagsFor_MapsAllFields(t *testing.T) {
|
|||||||
t.Errorf("+sheet-create --url should not be cobra-required: %+v", url)
|
t.Errorf("+sheet-create --url should not be cobra-required: %+v", url)
|
||||||
}
|
}
|
||||||
// hidden + int default
|
// hidden + int default
|
||||||
cap := byName("+cells-get", "cell-limit")
|
cap := byName("+cells-get", "max-chars")
|
||||||
if cap == nil || !cap.Hidden || cap.Default != "5000" {
|
if cap == nil || !cap.Hidden || cap.Default != "200000" {
|
||||||
t.Errorf("+cells-get --cell-limit not mapped: %+v", cap)
|
t.Errorf("+cells-get --max-chars not mapped: %+v", cap)
|
||||||
}
|
}
|
||||||
// input sources
|
// input sources
|
||||||
cells := byName("+cells-set", "cells")
|
cells := byName("+cells-set", "cells")
|
||||||
|
|||||||
@@ -19,6 +19,14 @@ import (
|
|||||||
// The sandbox tool (export_sheet_to_sandbox) is Sheet-Tool-only and has no
|
// The sandbox tool (export_sheet_to_sandbox) is Sheet-Tool-only and has no
|
||||||
// CLI surface here.
|
// CLI surface here.
|
||||||
|
|
||||||
|
// unboundedReadLimit is pinned into the tool's cell_limit / max_rows so that
|
||||||
|
// --max-chars is the single effective read cap. The underlying tools default
|
||||||
|
// those two to smaller values; without an explicit high value they could
|
||||||
|
// truncate before max_chars. The CLI no longer exposes --cell-limit / --max-rows
|
||||||
|
// (only --max-chars), so we pass this sentinel to neutralize the tool defaults.
|
||||||
|
// Large enough to never bind on any real sheet.
|
||||||
|
const unboundedReadLimit = 1_000_000_000
|
||||||
|
|
||||||
// CellsGet wraps get_cell_ranges: read multiple A1 ranges and return per-cell
|
// CellsGet wraps get_cell_ranges: read multiple A1 ranges and return per-cell
|
||||||
// values, formulas, styles, and other metadata as requested via --include.
|
// values, formulas, styles, and other metadata as requested via --include.
|
||||||
var CellsGet = common.Shortcut{
|
var CellsGet = common.Shortcut{
|
||||||
@@ -75,9 +83,10 @@ func cellsGetInput(runtime *common.RuntimeContext, token, sheetID, sheetName str
|
|||||||
if runtime.Bool("skip-hidden") {
|
if runtime.Bool("skip-hidden") {
|
||||||
input["skip_hidden"] = true
|
input["skip_hidden"] = true
|
||||||
}
|
}
|
||||||
if n := runtime.Int("cell-limit"); n > 0 {
|
// --cell-limit was removed from the CLI surface; --max-chars is the single
|
||||||
input["cell_limit"] = n
|
// read cap. Pin cell_limit very high so the tool's own default never binds
|
||||||
}
|
// before max_chars.
|
||||||
|
input["cell_limit"] = unboundedReadLimit
|
||||||
if n := runtime.Int("max-chars"); n > 0 {
|
if n := runtime.Int("max-chars"); n > 0 {
|
||||||
input["max_chars"] = n
|
input["max_chars"] = n
|
||||||
}
|
}
|
||||||
@@ -172,9 +181,10 @@ func csvGetInput(runtime *common.RuntimeContext, token, sheetID, sheetName strin
|
|||||||
if runtime.Bool("skip-hidden") {
|
if runtime.Bool("skip-hidden") {
|
||||||
input["skip_hidden"] = true
|
input["skip_hidden"] = true
|
||||||
}
|
}
|
||||||
if n := runtime.Int("max-rows"); n > 0 {
|
// --max-rows was removed from the CLI surface; --max-chars is the single
|
||||||
input["max_rows"] = n
|
// read cap. Pin max_rows very high so the tool's own default never binds
|
||||||
}
|
// before max_chars.
|
||||||
|
input["max_rows"] = unboundedReadLimit
|
||||||
if n := runtime.Int("max-chars"); n > 0 {
|
if n := runtime.Int("max-chars"); n > 0 {
|
||||||
input["max_chars"] = n
|
input["max_chars"] = n
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ func TestReadDataShortcuts_DryRun(t *testing.T) {
|
|||||||
"ranges": []interface{}{"A1:B2"},
|
"ranges": []interface{}{"A1:B2"},
|
||||||
"include_styles": true,
|
"include_styles": true,
|
||||||
"value_render_option": "formula",
|
"value_render_option": "formula",
|
||||||
|
"cell_limit": float64(unboundedReadLimit), // pinned high; --max-chars is the only cap
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -43,6 +44,7 @@ func TestReadDataShortcuts_DryRun(t *testing.T) {
|
|||||||
"sheet_id": testSheetID,
|
"sheet_id": testSheetID,
|
||||||
"range": "A1:C10",
|
"range": "A1:C10",
|
||||||
"value_render_option": "formula",
|
"value_render_option": "formula",
|
||||||
|
"max_rows": float64(unboundedReadLimit), // pinned high; --max-chars is the only cap
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user