Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion shortcuts/mail/flag_suggest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/spf13/pflag"

"github.com/larksuite/cli/errs"
"github.com/larksuite/cli/internal/cmdutil"
)

// flagName is a package-private snapshot of a pflag.Flag's identity.
Expand Down Expand Up @@ -48,11 +49,16 @@ const maxCandidates = 5
// Cobra's FlagErrorFunc walks up the parent chain looking for the nearest
// non-nil hook, so every mail subcommand inherits this behaviour without
// any per-shortcut wiring.
func InstallOnMail(svc *cobra.Command) {
func InstallOnMail(svc *cobra.Command, factories ...*cmdutil.Factory) {
if svc == nil {
return
}
svc.SetFlagErrorFunc(flagSuggestErrorFunc)
var f *cmdutil.Factory
if len(factories) > 0 {
f = factories[0]
}
installUserAllowBlockCommands(svc, f)
}

// flagSuggestErrorFunc converts pflag's unknown-flag errors into a typed
Expand Down
Loading
Loading