MCPcopy
hub / github.com/larksuite/cli / ExampleNewPlugin_observer

Function ExampleNewPlugin_observer

extension/platform/example_test.go:15–25  ·  view source on GitHub ↗

ExampleNewPlugin_observer registers an audit Observer that fires after every command, regardless of success or failure.

()

Source from the content-addressed store, hash-verified

13// ExampleNewPlugin_observer registers an audit Observer that fires
14// after every command, regardless of success or failure.
15func ExampleNewPlugin_observer() {
16 p, _ := platform.NewPlugin("audit", "0.1.0").
17 Observer(platform.After, "log", platform.All(),
18 func(ctx context.Context, inv platform.Invocation) {
19 _ = inv.Cmd().Path() // do something useful with the command
20 }).
21 FailOpen().
22 Build()
23 fmt.Println(p.Name(), p.Version())
24 // Output: audit 0.1.0
25}
26
27// ExampleNewPlugin_wrapper registers a Wrap that short-circuits any
28// write-class command. The framework converts the returned

Callers

nothing calls this directly

Calls 9

NewPluginFunction · 0.92
AllFunction · 0.92
FailOpenMethod · 0.80
ObserverMethod · 0.80
BuildMethod · 0.65
PathMethod · 0.65
CmdMethod · 0.65
NameMethod · 0.65
VersionMethod · 0.65

Tested by

no test coverage detected