forked from jeaniejung/Wildcard_Plugin
/
plugin.go
67 lines (60 loc) · 1.82 KB
/
plugin.go
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package plugin
import "github.com/cloudfoundry/cli/plugin/models"
/**
Command interface needs to be implemented for a runnable plugin of `cf`
**/
type Plugin interface {
Run(cliConnection CliConnection, args []string)
GetMetadata() PluginMetadata
}
/**
List of commands avaiable to CliConnection variable passed into run
**/
type CliConnection interface {
CliCommandWithoutTerminalOutput(args ...string) ([]string, error)
CliCommand(args ...string) ([]string, error)
GetCurrentOrg() (plugin_models.OrganizationSummary, error)
GetCurrentSpace() (plugin_models.SpaceSummary, error)
Username() (string, error)
UserGuid() (string, error)
UserEmail() (string, error)
IsLoggedIn() (bool, error)
IsSSLDisabled() (bool, error)
HasOrganization() (bool, error)
HasSpace() (bool, error)
ApiEndpoint() (string, error)
ApiVersion() (string, error)
HasAPIEndpoint() (bool, error)
LoggregatorEndpoint() (string, error)
DopplerEndpoint() (string, error)
AccessToken() (string, error)
GetApp(string) (plugin_models.Application, error)
GetApps() ([]plugin_models.ApplicationSummary, error)
GetOrgs() ([]plugin_models.OrganizationSummary, error)
GetSpaces() ([]plugin_models.SpaceSummary, error)
GetOrgUsers(string, ...string) ([]plugin_models.User, error)
GetSpaceUsers(string, string) ([]plugin_models.User, error)
GetServices() ([]plugin_models.ServiceInstance, error)
GetOrg(string) (plugin_models.Organization, error)
GetSpace(string) (plugin_models.Space, error)
}
type VersionType struct {
Major int
Minor int
Build int
}
type PluginMetadata struct {
Name string
Version VersionType
Commands []Command
}
type Usage struct {
Usage string
Options map[string]string
}
type Command struct {
Name string
Alias string
HelpText string
UsageDetails Usage //Detail usage to be displayed in `cf help <cmd>`
}