Skip to content

Commit dd333b0

Browse files
authored
Merge pull request #37 from choria-io/33
(#33) add basic readme
2 parents f9e1eaa + e7eac46 commit dd333b0

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

README.md

+38
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ and the usage will show these negatable booleans.
4040
Often though one does not want to have the negatable version of a boolean added, with fisk you can achieve this using
4141
our `UnNegatableBool()` which would just be the basic boolean flag with no negatable version.
4242

43+
Arguably `Bool()` should be un-negatable and we should have added a `NagatableBool()` but the decision was made to keep
44+
existing apps backward compatible.
45+
4346
### Cheats
4447

4548
I really like [cheat](https://github.com/cheat/cheat), a great little tool that gives access to bite-sized hints on what's great about a CLI tool.
@@ -88,3 +91,38 @@ Available Cheats:
8891

8992
You can save your cheats to a directory of your choice with `nats cheat --save /some/dir`, the directory
9093
must not already exist.
94+
95+
## External Plugins
96+
97+
Often one wants to make a CLI tool that can be extended using plugins. Think for example the `nats` CLI that is built
98+
using `fisk`, it may want to add some commercial offering-specific commands that appear in the `nats` command as a fully
99+
native built-in command.
100+
101+
**NOTE:** This is an experimental feature that will see some iteration in the short term future.
102+
103+
Fisk `0.5.0` supports extending itself at run-time in this manner and any application built using this version of fisk
104+
can be plugged into another fisk application.
105+
106+
The host application need to do some work but the ones being embedded will just work.
107+
108+
```go
109+
app := fisk.New("nats", "NATS Utility")
110+
111+
// now load your plugin models from disk and extend the command
112+
model := loadModelJson("ngs")
113+
114+
app.ExternalPluginCommand("/opt/nats/bin/ngs", model)
115+
```
116+
117+
The `model` above can be obtained by running a `fisk` built command with `--fisk-introspect` flag.
118+
119+
The idea is that you would detect and register new plugins into your tool, you would call them once with the introspect
120+
flag and cache that model. All future startups would embed this command - here `nats ngs` - right into the command flow.
121+
122+
The model is our [ApplicationModel](https://pkg.go.dev/github.com/choria-io/fisk#ApplicationModel). Plugins written in
123+
other languages or using other CLI frameworks would need to emit a compatible model.
124+
125+
Care should be taken not to have clashes with the top level global flags of the app you are embedding into, but if you
126+
do have a clash the value will be passed from top level into your app invocation. This should be good enough for most
127+
cases but could leed to some unexpected results when you might have a different concept of what a flag means than the one
128+
you are embedded into.

0 commit comments

Comments
 (0)