func (cmd *Push) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { var reqs []requirements.Requirement usageReq := requirementsFactory.NewUsageRequirement(commandregistry.CLICommandUsagePresenter(cmd), "", func() bool { return len(fc.Args()) > 1 }, ) reqs = append(reqs, usageReq) if fc.String("route-path") != "" { reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--route-path'", cf.RoutePathMinimumAPIVersion)) } if fc.String("app-ports") != "" { reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--app-ports'", cf.MultipleAppPortsMinimumAPIVersion)) } reqs = append(reqs, []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedSpaceRequirement(), }...) return reqs, nil }
func (cmd *Password) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), } return reqs, nil }
func (cmd *UnmapRoute) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires app_name, domain_name as arguments\n\n") + commandregistry.Commands.CommandUsage("unmap-route")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2) } if fc.IsSet("port") && (fc.IsSet("hostname") || fc.IsSet("path")) { cmd.ui.Failed(T("Cannot specify port together with hostname and/or path.")) return nil, fmt.Errorf("Cannot specify port together with hostname and/or path.") } domainName := fc.Args()[1] cmd.appReq = requirementsFactory.NewApplicationRequirement(fc.Args()[0]) cmd.domainReq = requirementsFactory.NewDomainRequirement(domainName) var reqs []requirements.Requirement if fc.String("path") != "" { reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--path'", cf.RoutePathMinimumAPIVersion)) } if fc.IsSet("port") { reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--port'", cf.TCPRoutingMinimumAPIVersion)) } reqs = append(reqs, []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), cmd.appReq, cmd.domainReq, }...) return reqs, nil }
func (cmd *DeleteSecurityGroup) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 1 { cmd.ui.Failed(T("Incorrect Usage. Requires an argument\n\n") + commandregistry.Commands.CommandUsage("delete-security-group")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1) } reqs := []requirements.Requirement{requirementsFactory.NewLoginRequirement()} return reqs, nil }
func (cmd *UpdateSecurityGroup) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires SECURITY_GROUP and PATH_TO_JSON_RULES_FILE as arguments\n\n") + commandregistry.Commands.CommandUsage("update-security-group")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2) } reqs := []requirements.Requirement{requirementsFactory.NewLoginRequirement()} return reqs, nil }
func (cmd *BindSecurityGroup) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 2 && len(fc.Args()) != 3 { cmd.ui.Failed(T("Incorrect Usage. Requires SECURITY_GROUP and ORG, optional SPACE as arguments\n\n") + commandregistry.Commands.CommandUsage("bind-security-group")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 3) } reqs := []requirements.Requirement{} reqs = append(reqs, requirementsFactory.NewLoginRequirement()) return reqs, nil }
func (cmd *UnbindSecurityGroup) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { argLength := len(fc.Args()) if argLength != 1 && argLength != 3 { cmd.ui.Failed(T("Incorrect Usage. Requires SECURITY_GROUP, ORG and SPACE as arguments\n\n") + commandregistry.Commands.CommandUsage("unbind-security-group")) return nil, fmt.Errorf("Incorrect usage: %d arguments of 1 or 3 required", len(fc.Args())) } reqs := []requirements.Requirement{requirementsFactory.NewLoginRequirement()} return reqs, nil }
func (cmd *SetRunningEnvironmentVariableGroup) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 1 { cmd.ui.Failed(T("Incorrect Usage. Requires an argument\n\n") + commandregistry.Commands.CommandUsage("set-running-environment-variable-group")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), } return reqs, nil }
func (cmd *ShowFeatureFlag) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 1 { cmd.ui.Failed(T("Incorrect Usage. Requires an argument\n\n") + commandregistry.Commands.CommandUsage("feature-flag")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), } return reqs, nil }
func (cmd *CreateBuildpack) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 3 { cmd.ui.Failed(T("Incorrect Usage. Requires buildpack_name, path and position as arguments\n\n") + commandregistry.Commands.CommandUsage("create-buildpack")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 3) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), } return reqs, nil }
func (cmd *UpdateServiceBroker) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 4 { cmd.ui.Failed(T("Incorrect Usage. Requires SERVICE_BROKER, USERNAME, PASSWORD, URL as arguments\n\n") + commandregistry.Commands.CommandUsage("update-service-broker")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 4) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), } return reqs, nil }
func (cmd *Curl) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 1 { cmd.ui.Failed(T("Incorrect Usage. An argument is missing or not correctly enclosed.\n\n") + commandregistry.Commands.CommandUsage("curl")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1) } reqs := []requirements.Requirement{ requirementsFactory.NewAPIEndpointRequirement(), } return reqs, nil }
func (cmd *RenameBuildpack) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires BUILDPACK_NAME, NEW_BUILDPACK_NAME as arguments\n\n") + commandregistry.Commands.CommandUsage("rename-buildpack")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), } return reqs, nil }
func (cmd *DeleteServiceKey) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires SERVICE_INSTANCE SERVICE_KEY as arguments\n\n") + commandregistry.Commands.CommandUsage("delete-service-key")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2) } loginRequirement := requirementsFactory.NewLoginRequirement() targetSpaceRequirement := requirementsFactory.NewTargetedSpaceRequirement() reqs := []requirements.Requirement{loginRequirement, targetSpaceRequirement} return reqs, nil }
func (cmd *Authenticate) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires 'username password' as arguments\n\n") + commandregistry.Commands.CommandUsage("auth")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2) } reqs := []requirements.Requirement{ requirementsFactory.NewAPIEndpointRequirement(), } return reqs, nil }
func (cmd *PurgeServiceInstance) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 1 { cmd.ui.Failed(T("Incorrect Usage. Requires an argument\n\n") + commandregistry.Commands.CommandUsage("purge-service-instance")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewMinAPIVersionRequirement("purge-service-instance", cf.RoutePathMinimumAPIVersion), } return reqs, nil }
func (cmd *CreateService) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 3 { cmd.ui.Failed(T("Incorrect Usage. Requires service, service plan, service instance as arguments\n\n") + commandregistry.Commands.CommandUsage("create-service")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 3) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedSpaceRequirement(), } return reqs, nil }
func (cmd *CreateUser) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 2 { usage := commandregistry.Commands.CommandUsage("create-user") cmd.ui.Failed(T("Incorrect Usage. Requires arguments\n\n") + usage) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), } return reqs, nil }
func (cmd *MigrateServiceInstances) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 5 { cmd.ui.Failed(T("Incorrect Usage. Requires v1_SERVICE v1_PROVIDER v1_PLAN v2_SERVICE v2_PLAN as arguments\n\n") + commandregistry.Commands.CommandUsage("migrate-service-instances")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 5) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewMaxAPIVersionRequirement("migrate-service-instances", cf.ServiceAuthTokenMaximumAPIVersion), } return reqs, nil }
func (cmd *UnsetSpaceQuota) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires SPACE and QUOTA as arguments\n\n") + commandregistry.Commands.CommandUsage("unset-space-quota")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), } return reqs, nil }
func (cmd *BindRouteService) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires DOMAIN and SERVICE_INSTANCE as arguments\n\n") + commandregistry.Commands.CommandUsage("bind-route-service")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2) } domainName := fc.Args()[0] cmd.domainReq = requirementsFactory.NewDomainRequirement(domainName) serviceName := fc.Args()[1] cmd.serviceInstanceReq = requirementsFactory.NewServiceInstanceRequirement(serviceName) minAPIVersionRequirement := requirementsFactory.NewMinAPIVersionRequirement( "bind-route-service", cf.MultipleAppPortsMinimumAPIVersion, ) reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), cmd.domainReq, cmd.serviceInstanceReq, minAPIVersionRequirement, } return reqs, nil }
func (cmd *SecurityGroups) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { usageReq := requirements.NewUsageRequirement(commandregistry.CLICommandUsagePresenter(cmd), T("No argument required"), func() bool { return len(fc.Args()) != 0 }, ) reqs := []requirements.Requirement{ usageReq, requirementsFactory.NewLoginRequirement(), } return reqs, nil }
func (cmd *CreateDomain) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires org_name, domain_name as arguments\n\n") + commandregistry.Commands.CommandUsage("create-domain")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2) } cmd.orgReq = requirementsFactory.NewOrganizationRequirement(fc.Args()[0]) reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), cmd.orgReq, } return reqs, nil }
func (cmd *MarketplaceServices) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { usageReq := requirements.NewUsageRequirement(commandregistry.CLICommandUsagePresenter(cmd), T("No argument required"), func() bool { return len(fc.Args()) != 0 }, ) reqs := []requirements.Requirement{ usageReq, requirementsFactory.NewAPIEndpointRequirement(), } return reqs, nil }
func (cmd *SetQuota) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires ORG_NAME, QUOTA as arguments\n\n") + commandregistry.Commands.CommandUsage("set-quota")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2) } cmd.orgReq = requirementsFactory.NewOrganizationRequirement(fc.Args()[0]) reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), cmd.orgReq, } return reqs, nil }
func (cmd *OrgUsers) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 1 { cmd.ui.Failed(T("Incorrect Usage. Requires an argument\n\n") + commandregistry.Commands.CommandUsage("org-users")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1) } cmd.orgReq = requirementsFactory.NewOrganizationRequirement(fc.Args()[0]) reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), cmd.orgReq, } return reqs, nil }
func (cmd *PurgeServiceOffering) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 1 { cmd.ui.Failed(T("Incorrect Usage. Requires an argument\n\n") + commandregistry.Commands.CommandUsage("purge-service-offering")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), } if fc.IsSet("p") { reqs = append(reqs, requirementsFactory.NewMaxAPIVersionRequirement("Option '-p'", cf.ServiceAuthTokenMaximumAPIVersion)) } return reqs, nil }
func (cmd *UpdateServiceAuthTokenFields) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 3 { cmd.ui.Failed(T("Incorrect Usage. Requires LABEL, PROVIDER and TOKEN as arguments\n\n") + commandregistry.Commands.CommandUsage("update-service-auth-token")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 3) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewMaxAPIVersionRequirement( "update-service-auth-token", cf.ServiceAuthTokenMaximumAPIVersion, ), } return reqs, nil }
func (cmd *DeleteSharedDomain) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 1 { cmd.ui.Failed(T("Incorrect Usage. Requires an argument\n\n") + commandregistry.Commands.CommandUsage("delete-shared-domain")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1) } loginReq := requirementsFactory.NewLoginRequirement() cmd.orgReq = requirementsFactory.NewTargetedOrgRequirement() reqs := []requirements.Requirement{ loginReq, cmd.orgReq, } return reqs, nil }
func (cmd *DeleteBuildpack) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { usageReq := requirements.NewUsageRequirement(commandregistry.CLICommandUsagePresenter(cmd), "", func() bool { return len(fc.Args()) != 1 }, ) loginReq := requirementsFactory.NewLoginRequirement() reqs := []requirements.Requirement{ usageReq, loginReq, } return reqs, nil }