Skip to content

Commit ff761be

Browse files
committed
docs: optimize base skill references
1 parent 0e6274d commit ff761be

129 files changed

Lines changed: 298 additions & 5337 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/service/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func NewCmdServiceMethodWithContext(ctx context.Context, f *cmdutil.Factory, spe
181181
cmd.Flags().StringVarP(&opts.JqExpr, "jq", "q", "", "jq expression to filter JSON output")
182182
cmd.Flags().BoolVar(&opts.DryRun, "dry-run", false, "print request without executing")
183183
if risk == "high-risk-write" {
184-
cmd.Flags().Bool("yes", false, "confirm high-risk operation")
184+
cmd.Flags().Bool("yes", false, cmdutil.HighRiskYesFlagHelp)
185185
}
186186

187187
// Conditionally register --file for methods with file-type fields.

cmd/service/service_risk_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ func TestServiceMethod_YesFlagRegisteredForHighRisk(t *testing.T) {
4242
f, _, _, _ := cmdutil.TestFactory(t, testConfig)
4343
cmd := NewCmdServiceMethod(f, driveSpec(), highRiskDeleteMethod(), "delete", "files", nil)
4444

45-
if cmd.Flags().Lookup("yes") == nil {
45+
flag := cmd.Flags().Lookup("yes")
46+
if flag == nil {
4647
t.Error("expected --yes flag registered for risk=high-risk-write")
4748
}
49+
if !strings.Contains(flag.Usage, "pass --yes without asking again") {
50+
t.Fatalf("--yes help missing agent guidance: %q", flag.Usage)
51+
}
4852
}
4953

5054
func TestServiceMethod_YesFlagNotRegisteredForWrite(t *testing.T) {

internal/cmdutil/confirm.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"github.com/larksuite/cli/internal/output"
1010
)
1111

12+
const HighRiskYesFlagHelp = "confirm high-risk operation; if the user explicitly requested it and the target is unambiguous, pass --yes without asking again"
13+
1214
// RequireConfirmation constructs a confirmation_required error with exit code
1315
// ExitConfirmationRequired and a structured Risk envelope. Used by both
1416
// shortcut and service command execution paths when a statically

shortcuts/base/base_advperm_disable.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ var BaseAdvpermDisable = common.Shortcut{
2525
Flags: []common.Flag{
2626
{Name: "base-token", Desc: "base token", Required: true},
2727
},
28+
Tips: []string{
29+
"Disabling advanced permissions invalidates existing custom roles; confirm the target Base before passing --yes.",
30+
},
2831
Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
2932
if strings.TrimSpace(runtime.Str("base-token")) == "" {
3033
return common.FlagErrorf("--base-token must not be blank")

shortcuts/base/base_copy.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ var BaseBaseCopy = common.Shortcut{
2424
{Name: "without-content", Type: "bool", Desc: "copy structure only"},
2525
{Name: "time-zone", Desc: "time zone, e.g. Asia/Shanghai"},
2626
},
27+
Tips: []string{
28+
`Example: lark-cli base +base-copy --base-token <base_token> --name "Copy of Project Tracker"`,
29+
"Use --without-content when the user wants only structure.",
30+
"If copied as bot, output may include permission_grant; report it so the user knows whether they can open the new Base.",
31+
},
2732
DryRun: dryRunBaseCopy,
2833
Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
2934
return executeBaseCopy(runtime)

shortcuts/base/base_create.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ var BaseBaseCreate = common.Shortcut{
2222
{Name: "folder-token", Desc: "folder token for destination"},
2323
{Name: "time-zone", Desc: "time zone, e.g. Asia/Shanghai"},
2424
},
25+
Tips: []string{
26+
`Example: lark-cli base +base-create --name "Project Tracker" --time-zone Asia/Shanghai`,
27+
"If created as bot, output may include permission_grant; report it so the user knows whether they can open the new Base.",
28+
},
2529
DryRun: dryRunBaseCreate,
2630
Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
2731
return executeBaseCreate(runtime)

shortcuts/base/base_execute_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ func TestBaseObjectJSONShortcutsRejectArrayInDryRun(t *testing.T) {
515515
if !strings.Contains(err.Error(), "--json must be a JSON object") {
516516
t.Fatalf("err=%v", err)
517517
}
518-
if !strings.Contains(err.Error(), "lark-base skill") {
518+
if !strings.Contains(err.Error(), "match the documented shape") {
519519
t.Fatalf("err=%v", err)
520520
}
521521
if strings.Contains(err.Error(), "array") {

shortcuts/base/base_form_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var BaseFormsList = common.Shortcut{
2323
Flags: []common.Flag{
2424
{Name: "base-token", Desc: "Base token (base_token)", Required: true},
2525
{Name: "table-id", Desc: "table ID", Required: true},
26-
{Name: "page-size", Type: "int", Default: "100", Desc: "page size per request (max 100)"},
26+
{Name: "page-size", Type: "int", Default: "100", Desc: "page size per request, max 100"},
2727
},
2828
DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
2929
return common.NewDryRunAPI().

shortcuts/base/base_role_create.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ var BaseRoleCreate = common.Shortcut{
2727
{Name: "base-token", Desc: "base token", Required: true},
2828
{Name: "json", Desc: `body JSON (AdvPermBaseRoleConfig), e.g. {"role_name":"Reviewer","role_type":"custom_role","table_rule_map":{...}}`, Required: true},
2929
},
30+
Tips: []string{
31+
`Example: --json '{"role_name":"Reviewer","role_type":"custom_role","base_rule_map":{"copy":false,"download":false}}'`,
32+
"Read role-config.md for table_rule_map, dashboard_rule_map, docx_rule_map, and filter permission JSON.",
33+
"Create supports custom_role only.",
34+
},
3035
Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
3136
if strings.TrimSpace(runtime.Str("base-token")) == "" {
3237
return common.FlagErrorf("--base-token must not be blank")

shortcuts/base/base_role_delete.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ var BaseRoleDelete = common.Shortcut{
2626
{Name: "base-token", Desc: "base token", Required: true},
2727
{Name: "role-id", Desc: "role ID (e.g. rolxxxxxx4)", Required: true},
2828
},
29+
Tips: []string{
30+
"Only custom roles can be deleted; system roles cannot be deleted.",
31+
"Use +role-get first if the role target is ambiguous, then pass --yes to confirm deletion.",
32+
},
2933
Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
3034
if strings.TrimSpace(runtime.Str("base-token")) == "" {
3135
return common.FlagErrorf("--base-token must not be blank")

0 commit comments

Comments
 (0)