mirror of
https://github.com/larksuite/cli.git
synced 2026-09-14 18:42:53 +08:00
525a98270f
* feat(docs): support comments and block mutation ranges * fix(docs): address CI and review feedback
61 lines
1.6 KiB
Go
61 lines
1.6 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package doc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/larksuite/cli/shortcuts/common"
|
|
)
|
|
|
|
// v1UpdateFlags returns hidden parse-only compatibility flags for old v1 commands.
|
|
func v1UpdateFlags() []common.Flag {
|
|
return docsLegacyFlagDefinitions(docsUpdateLegacyFlags())
|
|
}
|
|
|
|
var docsUpdateLocalResourceScopes = []string{
|
|
"docs:document.media:upload",
|
|
}
|
|
|
|
var docsUpdateWikiLocalResourceScopes = []string{
|
|
"docs:document.media:upload",
|
|
"wiki:node:retrieve",
|
|
}
|
|
|
|
func docsUpdateLocalResourceScopesFor(ref documentRef) []string {
|
|
if ref.Kind == "wiki" {
|
|
return docsUpdateWikiLocalResourceScopes
|
|
}
|
|
return docsUpdateLocalResourceScopes
|
|
}
|
|
|
|
var DocsUpdate = common.Shortcut{
|
|
Service: "docs",
|
|
Command: "+update",
|
|
Description: "Update a Lark document",
|
|
Risk: "write",
|
|
Scopes: []string{"docx:document:write_only", "docx:document:readonly"},
|
|
ConditionalScopes: docsUpdateWikiLocalResourceScopes,
|
|
AuthTypes: []string{"user", "bot"},
|
|
Flags: concatFlags(
|
|
[]common.Flag{
|
|
docsAPIVersionCompatFlag(),
|
|
docsOutputFormatCompatFlag(),
|
|
docsJSONOutputCompatFlag(),
|
|
{Name: "doc", Desc: "document URL or token", Required: true},
|
|
},
|
|
v2UpdateFlags(),
|
|
v1UpdateFlags(),
|
|
),
|
|
Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
|
|
return validateUpdateV2(ctx, runtime)
|
|
},
|
|
DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
|
|
return dryRunUpdateV2(ctx, runtime)
|
|
},
|
|
Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
|
|
return executeUpdateV2(ctx, runtime)
|
|
},
|
|
}
|