mirror of
https://github.com/larksuite/cli.git
synced 2026-07-03 14:02:43 +08:00
The 4 im query commands had three inconsistent sort conventions and leaked upstream API jargon (ByCreateTimeAsc, member_count_desc) directly to users. This PR unifies them on a single rule — --sort selects a field, --order selects a direction, both from fixed enums — so an agent only ever picks from an enum, never constructs a string. Old flags (--sort-type, --sort-by, and --sort on messages/threads) are kept as hidden silent aliases (no deprecation warning), so existing scripts keep working byte-for-byte.
19 lines
747 B
Go
19 lines
747 B
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package im
|
|
|
|
import "github.com/larksuite/cli/shortcuts/common"
|
|
|
|
// aliasFlagValue handles a renamed sort flag whose old name is kept as a silent
|
|
// alias. It returns (oldValue, true) only when the old flag was explicitly used
|
|
// and the new one was not; otherwise ("", false) — meaning "no old flag, or both
|
|
// given (new wins), so use the new-flag logic". Pure function, no IO: callable
|
|
// from DryRun, Execute, and minimal test fixtures alike. Never prints anything.
|
|
func aliasFlagValue(rt *common.RuntimeContext, oldName, newName string) (string, bool) {
|
|
if rt.Changed(oldName) && !rt.Changed(newName) {
|
|
return rt.Str(oldName), true
|
|
}
|
|
return "", false
|
|
}
|