You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d307a5b
Browse filesBrowse the repository at this point in the historyBrowse files
Output error message when a command is not found. Closes #778
Plugins with commands will need to implement a catch-all command that exits with the `DOKKU_NOT_IMPLEMENTED_EXIT`` code (10). This signals to dokku that a given plugin has indeed not executed anything for a plugin (which may not always be the case).
Using plugins that do not implement this pattern will result in those plugins silencing the error message.
Copy file name to clipboardExpand all lines: docs/plugins.md
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,49 @@ If you create your own plugin:
28
28
3. edit this page and add a link to it below!
29
29
4. subscribe to the [dokku development blog](http://progrium.com) to be notified about API changes and releases
30
30
31
+
### Sample plugin
32
+
33
+
The below plugin is a dummy `dokku hello` plugin. If your plugin exposes commands, this is a good template for your `commands` file:
34
+
35
+
```bash
36
+
#!/usr/bin/env bash
37
+
set -eo pipefail; [[ $DOKKU_TRACE ]] &&set -x
38
+
39
+
case"$1"in
40
+
hello)
41
+
[[ -z$2 ]] &&echo"Please specify an app to run the command on"&&exit 1
42
+
[[ !-d"$DOKKU_ROOT/$APP" ]] &&echo"App $APP does not exist"&&exit 1
43
+
APP="$2";
44
+
45
+
echo"Hello $APP"
46
+
;;
47
+
48
+
hello:world)
49
+
echo"Hello world"
50
+
;;
51
+
52
+
help)
53
+
cat && cat<<EOF
54
+
hello <app> Says "Hello <app>"
55
+
hello:world Says "Hello world"
56
+
EOF
57
+
;;
58
+
59
+
*)
60
+
exit$DOKKU_NOT_IMPLEMENTED_EXIT
61
+
;;
62
+
63
+
esac
64
+
```
65
+
66
+
A few notes:
67
+
68
+
- You should always support `DOKKU_TRACE` as specified on the 2nd line of the plugin.
69
+
- If your command requires that an application exists, ensure you check for it's existence in the manner prescribed above.
70
+
- A `help` command is required, though it is allowed to be empty.
71
+
- Commands *should* be namespaced.
72
+
- As of 0.3.3, a catch-all should be implemented which exits with a `DOKKU_NOT_IMPLEMENTED_EXIT` code. This allows dokku to output a `command not found` message.
73
+
31
74
## Community plugins
32
75
33
76
Note: The following plugins have been supplied by our community and may not have been tested by dokku maintainers.
0 commit comments