@@ -40,6 +40,9 @@ and the usage will show these negatable booleans.
40
40
Often though one does not want to have the negatable version of a boolean added, with fisk you can achieve this using
41
41
our ` UnNegatableBool() ` which would just be the basic boolean flag with no negatable version.
42
42
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
+
43
46
### Cheats
44
47
45
48
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:
88
91
89
92
You can save your cheats to a directory of your choice with ` nats cheat --save /some/dir ` , the directory
90
93
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