github.com/arunkumar7540/cli@v6.45.0+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 available 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 returns true if and only if the user is connected to the Cloud Controller API with the 27 // `--skip-ssl-validation` flag set unless the CLI configuration file cannot be read, in which case it 28 // returns an error. 29 IsSSLDisabled() (bool, error) 30 HasOrganization() (bool, error) 31 HasSpace() (bool, error) 32 ApiEndpoint() (string, error) 33 ApiVersion() (string, error) 34 HasAPIEndpoint() (bool, error) 35 LoggregatorEndpoint() (string, error) 36 DopplerEndpoint() (string, error) 37 AccessToken() (string, error) 38 GetApp(string) (plugin_models.GetAppModel, error) 39 GetApps() ([]plugin_models.GetAppsModel, error) 40 GetOrgs() ([]plugin_models.GetOrgs_Model, error) 41 GetSpaces() ([]plugin_models.GetSpaces_Model, error) 42 GetOrgUsers(string, ...string) ([]plugin_models.GetOrgUsers_Model, error) 43 GetSpaceUsers(string, string) ([]plugin_models.GetSpaceUsers_Model, error) 44 GetServices() ([]plugin_models.GetServices_Model, error) 45 GetService(string) (plugin_models.GetService_Model, error) 46 GetOrg(string) (plugin_models.GetOrg_Model, error) 47 GetSpace(string) (plugin_models.GetSpace_Model, error) 48 } 49 50 type VersionType struct { 51 Major int 52 Minor int 53 Build int 54 } 55 56 type PluginMetadata struct { 57 Name string 58 Version VersionType 59 MinCliVersion VersionType 60 Commands []Command 61 } 62 63 type Usage struct { 64 Usage string 65 Options map[string]string 66 } 67 68 type Command struct { 69 Name string 70 Alias string 71 HelpText string 72 UsageDetails Usage //Detail usage to be displayed in `cf help <cmd>` 73 }