-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugins.go
More file actions
48 lines (38 loc) · 988 Bytes
/
plugins.go
File metadata and controls
48 lines (38 loc) · 988 Bytes
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
44
45
46
47
48
package plugins
import "code.cloudfoundry.org/cli/v8/plugin"
type Plugin interface {
Execute(CliConnection, []string)
GetMetadata() plugin.PluginMetadata
}
type pluginWrapper struct {
plugin plugin.Plugin
}
func (p *pluginWrapper) Run(cliConnection plugin.CliConnection, args []string) {
connection, e := newCliConnection(cliConnection)
if e != nil {
panic(e)
}
p.plugin.Run(connection, args)
}
func (p *pluginWrapper) GetMetadata() plugin.PluginMetadata {
return p.plugin.GetMetadata()
}
type pluginConverter struct {
plugin Plugin
}
func (p *pluginConverter) Run(cliConnection plugin.CliConnection, args []string) {
connection, e := newCliConnection(cliConnection)
if e != nil {
panic(e)
}
p.plugin.Execute(connection, args)
}
func (p *pluginConverter) GetMetadata() plugin.PluginMetadata {
return p.plugin.GetMetadata()
}
func Start(cmd plugin.Plugin) {
plugin.Start(&pluginWrapper{cmd})
}
func Execute(cmd Plugin) {
plugin.Start(&pluginConverter{cmd})
}