github.com/elopio/cli@v6.21.2-0.20160902224010-ea909d1fdb2f+incompatible/plugin/plugin.go (about) 1 package plugin 2 3 import "code.cloudfoundry.org/cli/plugin/models" 4 5 /** 6 Command interface needs to be implemented for a runnable plugin of `cf` 7 **/ 8 type Plugin interface { 9 Run(cliConnection CliConnection, args []string) 10 GetMetadata() PluginMetadata 11 } 12 13 //go:generate counterfeiter . CliConnection 14 /** 15 List of commands avaiable to CliConnection variable passed into run 16 **/ 17 type CliConnection interface { 18 CliCommandWithoutTerminalOutput(args ...string) ([]string, error) 19 CliCommand(args ...string) ([]string, error) 20 GetCurrentOrg() (plugin_models.Organization, error) 21 GetCurrentSpace() (plugin_models.Space, error) 22 Username() (string, error) 23 UserGuid() (string, error) 24 UserEmail() (string, error) 25 IsLoggedIn() (bool, error) 26 IsSSLDisabled() (bool, error) 27 HasOrganization() (bool, error) 28 HasSpace() (bool, error) 29 ApiEndpoint() (string, error) 30 ApiVersion() (string, error) 31 HasAPIEndpoint() (bool, error) 32 LoggregatorEndpoint() (string, error) 33 DopplerEndpoint() (string, error) 34 AccessToken() (string, error) 35 GetApp(string) (plugin_models.GetAppModel, error) 36 GetApps() ([]plugin_models.GetAppsModel, error) 37 GetOrgs() ([]plugin_models.GetOrgs_Model, error) 38 GetSpaces() ([]plugin_models.GetSpaces_Model, error) 39 GetOrgUsers(string, ...string) ([]plugin_models.GetOrgUsers_Model, error) 40 GetSpaceUsers(string, string) ([]plugin_models.GetSpaceUsers_Model, error) 41 GetServices() ([]plugin_models.GetServices_Model, error) 42 GetService(string) (plugin_models.GetService_Model, error) 43 GetOrg(string) (plugin_models.GetOrg_Model, error) 44 GetSpace(string) (plugin_models.GetSpace_Model, error) 45 } 46 47 type VersionType struct { 48 Major int 49 Minor int 50 Build int 51 } 52 53 type PluginMetadata struct { 54 Name string 55 Version VersionType 56 MinCliVersion VersionType 57 Commands []Command 58 } 59 60 type Usage struct { 61 Usage string 62 Options map[string]string 63 } 64 65 type Command struct { 66 Name string 67 Alias string 68 HelpText string 69 UsageDetails Usage //Detail usage to be displayed in `cf help <cmd>` 70 }