mirror of
https://github.com/larksuite/cli.git
synced 2026-07-03 14:02:43 +08:00
A pure group invoked with flags but no subcommand (e.g. `im --format=json`,
`sheets --format json`) silently fell through to help + exit 0, so an agent
could mistake a malformed call for success. The unknown-subcommand guard's
FParseErrWhitelist swallows the flags and leaves RunE with empty args; it now
recovers the raw flag tokens and fails structured:
- unknown flag(s) -> unknown_flag (unchanged)
- valid flag, no subcmd -> missing_subcommand (new, exit 2)
- bare group -> help, exit 0 (unchanged)
Because the group RunE is hook-wrapped, returning a real error also makes
plugin observers record the call as failed instead of ok (the lifecycle Err
is no longer flipped to nil).
Hardening from the same review:
- document the cobra error-text contract unknownFlagName relies on, in
both cmd/root.go and go.mod, so an i18n/reword is caught on upgrade.
- guard the reserved --print-schema/--flag-name registration with a Lookup
so a shortcut declaring same-named flags can't panic pflag.
Tests cover the new missing_subcommand path and the reserved-flag collision.
67 lines
2.8 KiB
Modula-2
67 lines
2.8 KiB
Modula-2
module github.com/larksuite/cli
|
|
|
|
go 1.23.0
|
|
|
|
require (
|
|
github.com/Microsoft/go-winio v0.6.2
|
|
github.com/bmatcuk/doublestar/v4 v4.10.0
|
|
github.com/charmbracelet/huh v1.0.0
|
|
github.com/charmbracelet/lipgloss v1.1.0
|
|
github.com/gofrs/flock v0.8.1
|
|
github.com/google/uuid v1.6.0
|
|
github.com/itchyny/gojq v0.12.17
|
|
github.com/larksuite/oapi-sdk-go/v3 v3.5.4
|
|
github.com/sergi/go-diff v1.4.0
|
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
|
github.com/smartystreets/goconvey v1.8.1
|
|
github.com/spf13/cobra v1.10.2 // flag-error-text contract: see cmd/root.go unknownFlagName
|
|
github.com/spf13/pflag v1.0.9
|
|
github.com/stretchr/testify v1.11.1
|
|
github.com/tidwall/gjson v1.18.0
|
|
github.com/zalando/go-keyring v0.2.8
|
|
golang.org/x/net v0.33.0
|
|
golang.org/x/sync v0.15.0
|
|
golang.org/x/sys v0.33.0
|
|
golang.org/x/term v0.27.0
|
|
golang.org/x/text v0.23.0
|
|
gopkg.in/yaml.v3 v3.0.1
|
|
)
|
|
|
|
require (
|
|
github.com/atotto/clipboard v0.1.4 // indirect
|
|
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
|
github.com/catppuccin/go v0.3.0 // indirect
|
|
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 // indirect
|
|
github.com/charmbracelet/bubbletea v1.3.6 // indirect
|
|
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
|
|
github.com/charmbracelet/x/ansi v0.9.3 // indirect
|
|
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
|
|
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
|
|
github.com/charmbracelet/x/term v0.2.1 // indirect
|
|
github.com/danieljoos/wincred v1.2.3 // indirect
|
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
|
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
|
|
github.com/godbus/dbus/v5 v5.2.2 // indirect
|
|
github.com/gogo/protobuf v1.3.2 // indirect
|
|
github.com/gopherjs/gopherjs v1.17.2 // indirect
|
|
github.com/gorilla/websocket v1.5.0 // indirect
|
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
|
github.com/itchyny/timefmt-go v0.1.6 // indirect
|
|
github.com/jtolds/gls v4.20.0+incompatible // indirect
|
|
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
|
github.com/mattn/go-localereader v0.0.1 // indirect
|
|
github.com/mattn/go-runewidth v0.0.16 // indirect
|
|
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
|
|
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
|
|
github.com/muesli/cancelreader v0.2.2 // indirect
|
|
github.com/muesli/termenv v0.16.0 // indirect
|
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
|
github.com/rivo/uniseg v0.4.7 // indirect
|
|
github.com/smarty/assertions v1.15.0 // indirect
|
|
github.com/tidwall/match v1.1.1 // indirect
|
|
github.com/tidwall/pretty v1.2.0 // indirect
|
|
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
|
)
|