bf9395e022
CI / license-header (push) Has been skipped
CI / e2e-dry-run (push) Has been skipped
CI / fast-gate (push) Failing after 0s
Test PR Label Logic / test-pr-labels (push) Failing after 1s
Skill Format Check / check-format (push) Failing after 2s
CI / security (push) Failing after 5s
CI / unit-test (push) Has been skipped
CI / lint (push) Has been skipped
CI / script-test (push) Has been skipped
CI / deterministic-gate (push) Has been skipped
CI / coverage (push) Has been skipped
CI / results (push) Has been cancelled
CI / deadcode (push) Has been cancelled
CI / e2e-live (push) Has been cancelled
27 lines
833 B
Markdown
27 lines
833 B
Markdown
# Example: audit observer
|
|
|
|
The simplest possible lark-cli plugin: one After observer that logs
|
|
every dispatched command to stderr (success or failure).
|
|
|
|
## Build & run
|
|
|
|
```sh
|
|
cd extension/platform/examples/audit-observer
|
|
go build -o audit-cli .
|
|
./audit-cli config plugins show
|
|
# {"plugins":[{"name":"audit", ...}], "total":1}
|
|
|
|
./audit-cli api GET /open-apis/contact/v3/users/me
|
|
# [audit] api ok (on stderr)
|
|
```
|
|
|
|
## Key points
|
|
|
|
- `platform.NewPlugin(...).MustBuild()` from `init()`. The blank
|
|
import of this package in `main.go` triggers `init()`.
|
|
- `Observer(platform.After, ...)` runs **after** the command's RunE,
|
|
even on failure (Observers cannot prevent execution).
|
|
- `FailOpen()` means: if Install ever fails, the binary logs a
|
|
warning and continues without this plugin. Right default for
|
|
audit-only plugins.
|