Files
larksuite__cli/shortcuts/common/flag_aliases.go
liangshuo-1 2a1613484a feat: add framework flag aliases and unified IM pagination (#2146)
* feat: add framework flag aliases and unified IM pagination

Introduce declarative exact-name flag aliases at the shortcut framework boundary while keeping semantic compatibility domain-owned. Add a shared, format-aware IM pagination pipeline with consistent flags, metadata, safety bounds, resumable cursors, and request throttling.

* fix: align alias attribution and pagination contracts

* fix: align alias contracts and documentation

* test: remove environment-dependent contact bot e2e

* test: restore contact bot e2e

* docs: reduce IM pagination guidance noise

---------

Co-authored-by: liangshuo-1 <266696938+liangshuo-1@users.noreply.github.com>
2026-08-03 19:20:40 +08:00

30 lines
1.1 KiB
Go

// Copyright (c) 2026 Lark Technologies Pte. Ltd.
// SPDX-License-Identifier: MIT
package common
import (
"github.com/larksuite/cli/internal/flagalias"
"github.com/spf13/cobra"
)
// installFlagAliases makes declarative Flag.Aliases parse-time synonyms for
// their canonical flag. Only the canonical pflag is registered, so aliases
// automatically share its type, default, enum, required, input, help, and
// schema contracts. Downstream code therefore reads only the canonical name.
//
// Aliases use the canonical flag type's normal repeated-flag semantics. For
// scalar flags, the last canonical/alias occurrence wins; collection flags
// retain pflag's accumulation behavior. Value-transforming compatibility
// inputs are not aliases and use the framework Normalize phase instead.
func installFlagAliases(cmd *cobra.Command, flags []Flag) {
specs := make([]flagalias.Spec, 0)
for _, flag := range flags {
if len(flag.Aliases) == 0 {
continue
}
specs = append(specs, flagalias.Spec{Canonical: flag.Name, Aliases: flag.Aliases})
}
flagalias.MustBind(cmd, specs)
}