Files
larksuite__cli/shortcuts/base/record_get.go
zgz2048 cb1bb1d004 docs(base): restructure skill routing and analysis guidance (#2320)
* docs(base): add common filter condition examples

* docs(base): restructure skill routing and guidance

* docs(base): simplify identity selection guidance

* docs(base): restore concise recovery contracts

* docs(base): condense recovery guidance

* docs(base): retain only high-value recovery guidance

* docs(base): clarify full field update semantics

* docs(base): prioritize common text filter examples

* docs(base): deduplicate auto number update guidance

* fix(base): align ndjson dry-run page size

* docs(base): align permission identity guidance

* test(base): align ndjson dry-run page size

* docs(base): recommend dynamic select option reuse

* docs(base): require SOP for record reads

* docs(base): streamline record read guidance

* docs(base): clarify record format guidance

* docs(base): reduce hidden record flag exposure

* docs(base): merge record read gate

* docs(base): reduce table discovery guidance

* docs(base): centralize block discovery guidance

* docs(base): restore table analysis chain

* docs(base): restore table resource guidance

* docs(base): use resource-specific list commands

* docs(base): restore folder listing command

* docs(base): minimize probe stdout
2026-08-14 13:35:44 +08:00

60 lines
2.2 KiB
Go

// Copyright (c) 2026 Lark Technologies Pte. Ltd.
// SPDX-License-Identifier: MIT
package base
import (
"context"
"github.com/larksuite/cli/shortcuts/common"
"github.com/spf13/cobra"
)
var BaseRecordGet = common.Shortcut{
Service: "base",
Command: "+record-get",
Description: "Get one or more records by ID",
Risk: "read",
Scopes: []string{"base:record:read"},
AuthTypes: authTypes(),
Flags: []common.Flag{
baseTokenFlag(true),
tableRefFlag(true),
{Name: "record-id", Type: "string_array", Desc: "record ID (repeatable)"},
recordProjectionFieldFlag("field ID or name to project; repeat to keep only needed columns"),
recordProjectionAliasFlag("fields"),
recordProjectionAliasFlag("field-names"),
{Name: "json", Desc: `JSON object with record_id_list, e.g. {"record_id_list":["rec_xxx"]}`},
recordReadFormatFlag(),
recordOutputFlag(),
recordMinimalStdoutFlag(),
recordJQRecordsFlag(),
recordOverwriteFlag(),
},
Normalize: normalizeRecordReadOutput,
Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
if err := validateRecordReadFormat(runtime); err != nil {
return err
}
if err := validateRecordExportFlags(runtime); err != nil {
return err
}
return validateRecordSelection(runtime)
},
Tips: []string{
"Example: lark-cli base +record-get --base-token <base_token> --table-id <table_id> --record-id <record_id>",
"Example with projection: lark-cli base +record-get --base-token <base_token> --table-id <table_id> --record-id rec_001 --record-id rec_002 --field-id Name --field-id Status",
"Example for analysis input: lark-cli base +record-get --base-token <base_token> --table-id <table_id> --record-id <record_id> --field-id <field> --format ndjson --output ./record.ndjson",
recordAnalysisOutputTip,
"Use --field-id as a projection boundary to avoid loading large cell values into context when they are not needed.",
"Use +record-get when record_id is already known; otherwise use +record-search or +record-list.",
},
DryRun: dryRunRecordGet,
PostMount: func(cmd *cobra.Command) {
preserveFlagOrder(cmd)
},
Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
return executeRecordGet(runtime)
},
}