forked from cloudfoundry/docs-cf-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevelop-cli-plugins.html.md.erb
More file actions
43 lines (28 loc) · 1.94 KB
/
develop-cli-plugins.html.md.erb
File metadata and controls
43 lines (28 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
title: Developing cf CLI Plugins
owner: CLI
---
<strong><%= modified_date %></strong>
Users can create and install Cloud Foundry Command Line Interface (cf CLI) plugins to provide custom commands.
These plugins can be submitted and shared to the [CF Community repository](https://plugins.cloudfoundry.org/).
### Requirements ###
Using plugins requires cf CLI v.6.7 or higher.
Refer to the [Installing the Cloud Foundry Command Line Interface](./install-go-cli.html) topic for information about downloading, installing, and uninstalling the cf CLI.
### Installing the Architecture ###
1. Implement the [predefined plugin interface](https://github.com/cloudfoundry/cli/blob/master/plugin/plugin.go).
1. Clone the [template repository](https://github.com/cloudfoundry/cli). You will need the [basic GO plugin](https://github.com/cloudfoundry/cli/blob/master/plugin/plugin_examples/basic_plugin.go).
### Initializing the Plugin ###
To initialize a plugin, call `plugin.Start(new(MyPluginStruct))` from within
the `main()` method of your plugin.
The `plugin.Start(...)` function requires a new reference to the `struct` that
implements the defined interface.
### Invoking cf CLI Commands ###
Invoke cf CLI commands with `cliConnection.CliCommand([]args)` from within a plugin's `Run(...)` method.
`The Run(...)` method receives the `cliConnection` as its first argument.
The `cliConnection.CliCommand([]args)` returns the output printed by the command and an error.
The output is returned as a slice of strings.
The error will be present if the call to the cf CLI command fails.
For more information, see the [API commands documentation](https://github.com/cloudfoundry/cli/blob/master/plugin/plugin_examples/DOC.md).
### Installing a Plugin ###
To install a plugin, run `cf install-plugin PATH_TO_PLUGIN_BINARY`.
For additional information about developing plugins, see the [plugin development guide](https://github.com/cloudfoundry/cli/tree/master/plugin/plugin_examples).