mirror of
https://github.com/larksuite/cli.git
synced 2026-07-03 14:02:43 +08:00
fix(sheets): replace undefined common.FlagErrorf with sheetsValidationForFlag
changesetRevisions called common.FlagErrorf, which does not exist, breaking the build. Use sheetsValidationForFlag so the errors carry the offending flag param like the rest of the sheets validation paths. Also reword two doc comments in lark_sheet_history_revert.go that used '' for an empty shell string: gofmt (Go 1.19+) rewrites '' in doc comments to a curly quote, leaving the file permanently unformatted.
This commit is contained in:
@@ -75,14 +75,14 @@ func changesetRevisions(runtime flagView) (start int, end int, err error) {
|
||||
start = runtime.Int("start-revision")
|
||||
end = runtime.Int("end-revision")
|
||||
if start < 1 {
|
||||
return 0, 0, common.FlagErrorf("--start-revision must be >= 1")
|
||||
return 0, 0, sheetsValidationForFlag("start-revision", "--start-revision must be >= 1")
|
||||
}
|
||||
if end > 0 {
|
||||
if end < start {
|
||||
return 0, 0, common.FlagErrorf("--end-revision (%d) must be >= --start-revision (%d)", end, start)
|
||||
return 0, 0, sheetsValidationForFlag("end-revision", "--end-revision (%d) must be >= --start-revision (%d)", end, start)
|
||||
}
|
||||
if end-start+1 > changesetMaxRevGap {
|
||||
return 0, 0, common.FlagErrorf("version gap exceeds limit %d (start=%d, end=%d)", changesetMaxRevGap, start, end)
|
||||
return 0, 0, sheetsValidationForFlag("end-revision", "version gap exceeds limit %d (start=%d, end=%d)", changesetMaxRevGap, start, end)
|
||||
}
|
||||
}
|
||||
return start, end, nil
|
||||
|
||||
@@ -73,7 +73,8 @@ func historyRevertInput(token, versionID string) map[string]interface{} {
|
||||
// history version id — the facade-agg status tool keys on transaction_id).
|
||||
// Required at the cli surface (cobra MarkFlagRequired) — same gating model as
|
||||
// historyVersionIDFlag. Validate still trims + rejects empty/control-char
|
||||
// values to catch the "--transaction-id ''" cobra-accepts-but-empty case.
|
||||
// values to catch the case where cobra accepts --transaction-id with an
|
||||
// empty-string value.
|
||||
func transactionIDFlag() common.Flag {
|
||||
return common.Flag{
|
||||
Name: "transaction-id",
|
||||
@@ -110,7 +111,7 @@ func historyRevertStatusInput(token, transactionID string) map[string]interface{
|
||||
// Validate runs with cobra's standard "required flag(s)" error (which the
|
||||
// dispatcher classifies as a typed *errs.ValidationError, exit 2). We still
|
||||
// trim + reject empty / control-char values in Validate to catch the
|
||||
// "--history-version-id ''" cobra-accepts-but-empty case.
|
||||
// case where cobra accepts --history-version-id with an empty-string value.
|
||||
var HistoryRevert = common.Shortcut{
|
||||
Service: "sheets",
|
||||
Command: "+history-revert",
|
||||
|
||||
Reference in New Issue
Block a user