ExampleNewPlugin_observer registers an audit Observer that fires after every command, regardless of success or failure.
()
| 13 | // ExampleNewPlugin_observer registers an audit Observer that fires |
| 14 | // after every command, regardless of success or failure. |
| 15 | func 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 |