本文整理汇总了Golang中github.com/simonleung8/flags.FlagContext类的典型用法代码示例。如果您正苦于以下问题:Golang FlagContext类的具体用法?Golang FlagContext怎么用?Golang FlagContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FlagContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Requirements
func (cmd *EnableServiceAccess) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) (reqs []requirements.Requirement, err error) {
if len(fc.Args()) != 1 {
cmd.ui.Failed(T("Incorrect Usage. Requires an argument\n\n") + command_registry.Commands.CommandUsage("enable-service-access"))
}
return []requirements.Requirement{requirementsFactory.NewLoginRequirement()}, nil
}
开发者ID:Doebe,项目名称:workplace,代码行数:7,代码来源:enable_service_access.go
示例2: Execute
func (cmd *ShowService) Execute(c flags.FlagContext) {
serviceInstance := cmd.serviceInstanceReq.GetServiceInstance()
if cmd.pluginCall {
cmd.populatePluginModel(serviceInstance)
return
}
if c.Bool("guid") {
cmd.ui.Say(serviceInstance.Guid)
} else {
cmd.ui.Say("")
cmd.ui.Say(T("Service instance: {{.ServiceName}}", map[string]interface{}{"ServiceName": terminal.EntityNameColor(serviceInstance.Name)}))
if serviceInstance.IsUserProvided() {
cmd.ui.Say(T("Service: {{.ServiceDescription}}",
map[string]interface{}{
"ServiceDescription": terminal.EntityNameColor(T("user-provided")),
}))
} else {
cmd.ui.Say(T("Service: {{.ServiceDescription}}",
map[string]interface{}{
"ServiceDescription": terminal.EntityNameColor(serviceInstance.ServiceOffering.Label),
}))
cmd.ui.Say(T("Plan: {{.ServicePlanName}}",
map[string]interface{}{
"ServicePlanName": terminal.EntityNameColor(serviceInstance.ServicePlan.Name),
}))
cmd.ui.Say(T("Description: {{.ServiceDescription}}", map[string]interface{}{"ServiceDescription": terminal.EntityNameColor(serviceInstance.ServiceOffering.Description)}))
cmd.ui.Say(T("Documentation url: {{.URL}}",
map[string]interface{}{
"URL": terminal.EntityNameColor(serviceInstance.ServiceOffering.DocumentationUrl),
}))
cmd.ui.Say(T("Dashboard: {{.URL}}",
map[string]interface{}{
"URL": terminal.EntityNameColor(serviceInstance.DashboardUrl),
}))
cmd.ui.Say("")
cmd.ui.Say(T("Last Operation"))
cmd.ui.Say(T("Status: {{.State}}",
map[string]interface{}{
"State": terminal.EntityNameColor(ServiceInstanceStateToStatus(serviceInstance.LastOperation.Type, serviceInstance.LastOperation.State, serviceInstance.IsUserProvided())),
}))
cmd.ui.Say(T("Message: {{.Message}}",
map[string]interface{}{
"Message": terminal.EntityNameColor(serviceInstance.LastOperation.Description),
}))
if "" != serviceInstance.LastOperation.CreatedAt {
cmd.ui.Say(T("Started: {{.Started}}",
map[string]interface{}{
"Started": terminal.EntityNameColor(serviceInstance.LastOperation.CreatedAt),
}))
}
cmd.ui.Say(T("Updated: {{.Updated}}",
map[string]interface{}{
"Updated": terminal.EntityNameColor(serviceInstance.LastOperation.UpdatedAt),
}))
}
}
}
开发者ID:Doebe,项目名称:workplace,代码行数:60,代码来源:service.go
示例3: Execute
func (cmd *UnsetSpaceRole) Execute(c flags.FlagContext) {
spaceName := c.Args()[2]
role := models.UserInputToSpaceRole[c.Args()[3]]
user := cmd.userReq.GetUser()
org := cmd.orgReq.GetOrganization()
space, err := cmd.spaceRepo.FindByNameInOrg(spaceName, org.Guid)
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Say(T("Removing role {{.Role}} from user {{.TargetUser}} in org {{.TargetOrg}} / space {{.TargetSpace}} as {{.CurrentUser}}...",
map[string]interface{}{
"Role": terminal.EntityNameColor(role),
"TargetUser": terminal.EntityNameColor(user.Username),
"TargetOrg": terminal.EntityNameColor(org.Name),
"TargetSpace": terminal.EntityNameColor(space.Name),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
if len(user.Guid) > 0 {
err = cmd.userRepo.UnsetSpaceRoleByGuid(user.Guid, space.Guid, role)
} else {
err = cmd.userRepo.UnsetSpaceRoleByUsername(user.Username, space.Guid, role)
}
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Ok()
}
开发者ID:Doebe,项目名称:workplace,代码行数:30,代码来源:unset_space_role.go
示例4: Execute
func (cmd *DeleteSecurityGroup) Execute(context flags.FlagContext) {
name := context.Args()[0]
cmd.ui.Say(T("Deleting security group {{.security_group}} as {{.username}}",
map[string]interface{}{
"security_group": terminal.EntityNameColor(name),
"username": terminal.EntityNameColor(cmd.configRepo.Username()),
}))
if !context.Bool("f") {
response := cmd.ui.ConfirmDelete(T("security group"), name)
if !response {
return
}
}
group, err := cmd.securityGroupRepo.Read(name)
switch err.(type) {
case nil:
case *errors.ModelNotFoundError:
cmd.ui.Ok()
cmd.ui.Warn(T("Security group {{.security_group}} does not exist", map[string]interface{}{"security_group": name}))
return
default:
cmd.ui.Failed(err.Error())
}
err = cmd.securityGroupRepo.Delete(group.Guid)
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Ok()
}
开发者ID:Doebe,项目名称:workplace,代码行数:33,代码来源:delete_security_group.go
示例5: Requirements
func (cmd *AddPluginRepo) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) (reqs []requirements.Requirement, err error) {
if len(fc.Args()) != 2 {
cmd.ui.Failed(T("Incorrect Usage. Requires [REPO_NAME] [URL] as arguments\n\n") + command_registry.Commands.CommandUsage("add-plugin-repo"))
}
return
}
开发者ID:Doebe,项目名称:workplace,代码行数:7,代码来源:add_plugin_repo.go
示例6: Execute
func (cmd *SetEnv) Execute(c flags.FlagContext) {
varName := c.Args()[1]
varValue := c.Args()[2]
app := cmd.appReq.GetApplication()
cmd.ui.Say(T("Setting env variable '{{.VarName}}' to '{{.VarValue}}' for app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.CurrentUser}}...",
map[string]interface{}{
"VarName": terminal.EntityNameColor(varName),
"VarValue": terminal.EntityNameColor(varValue),
"AppName": terminal.EntityNameColor(app.Name),
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username())}))
if len(app.EnvironmentVars) == 0 {
app.EnvironmentVars = map[string]interface{}{}
}
envParams := app.EnvironmentVars
envParams[varName] = varValue
_, apiErr := cmd.appRepo.Update(app.Guid, models.AppParams{EnvironmentVars: &envParams})
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
cmd.ui.Say(T("TIP: Use '{{.Command}}' to ensure your env variable changes take effect",
map[string]interface{}{"Command": terminal.CommandColor(cf.Name() + " restage")}))
}
开发者ID:Doebe,项目名称:workplace,代码行数:31,代码来源:set_env.go
示例7: Execute
func (cmd *CreateServiceKey) Execute(c flags.FlagContext) {
serviceInstance := cmd.serviceInstanceRequirement.GetServiceInstance()
serviceKeyName := c.Args()[1]
params := c.String("c")
paramsMap, err := json.ParseJsonFromFileOrString(params)
if err != nil {
cmd.ui.Failed(T("Invalid configuration provided for -c flag. Please provide a valid JSON object or path to a file containing a valid JSON object."))
}
cmd.ui.Say(T("Creating service key {{.ServiceKeyName}} for service instance {{.ServiceInstanceName}} as {{.CurrentUser}}...",
map[string]interface{}{
"ServiceInstanceName": terminal.EntityNameColor(serviceInstance.Name),
"ServiceKeyName": terminal.EntityNameColor(serviceKeyName),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
err = cmd.serviceKeyRepo.CreateServiceKey(serviceInstance.Guid, serviceKeyName, paramsMap)
switch err.(type) {
case nil:
cmd.ui.Ok()
case *errors.ModelAlreadyExistsError:
cmd.ui.Ok()
cmd.ui.Warn(err.Error())
default:
cmd.ui.Failed(err.Error())
}
}
开发者ID:Doebe,项目名称:workplace,代码行数:28,代码来源:create_service_key.go
示例8: Execute
func (cmd *DeleteServiceBroker) Execute(c flags.FlagContext) {
brokerName := c.Args()[0]
if !c.Bool("f") && !cmd.ui.ConfirmDelete(T("service-broker"), brokerName) {
return
}
cmd.ui.Say(T("Deleting service broker {{.Name}} as {{.Username}}...",
map[string]interface{}{
"Name": terminal.EntityNameColor(brokerName),
"Username": terminal.EntityNameColor(cmd.config.Username()),
}))
broker, apiErr := cmd.repo.FindByName(brokerName)
switch apiErr.(type) {
case nil:
case *errors.ModelNotFoundError:
cmd.ui.Ok()
cmd.ui.Warn(T("Service Broker {{.Name}} does not exist.", map[string]interface{}{"Name": brokerName}))
return
default:
cmd.ui.Failed(apiErr.Error())
return
}
apiErr = cmd.repo.Delete(broker.Guid)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
return
}
开发者ID:Doebe,项目名称:workplace,代码行数:34,代码来源:delete_service_broker.go
示例9: Execute
func (cmd *UpdateSecurityGroup) Execute(context flags.FlagContext) {
name := context.Args()[0]
securityGroup, err := cmd.securityGroupRepo.Read(name)
if err != nil {
cmd.ui.Failed(err.Error())
}
pathToJSONFile := context.Args()[1]
rules, err := json.ParseJsonArray(pathToJSONFile)
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Say(T("Updating security group {{.security_group}} as {{.username}}",
map[string]interface{}{
"security_group": terminal.EntityNameColor(name),
"username": terminal.EntityNameColor(cmd.configRepo.Username()),
}))
err = cmd.securityGroupRepo.Update(securityGroup.Guid, rules)
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Ok()
cmd.ui.Say("\n\n")
cmd.ui.Say(T("TIP: Changes will not apply to existing running applications until they are restarted."))
}
开发者ID:Doebe,项目名称:workplace,代码行数:27,代码来源:update_security_group.go
示例10: Execute
func (cmd *SetSpaceQuota) Execute(c flags.FlagContext) {
spaceName := c.Args()[0]
quotaName := c.Args()[1]
cmd.ui.Say(T("Assigning space quota {{.QuotaName}} to space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{
"QuotaName": terminal.EntityNameColor(quotaName),
"SpaceName": terminal.EntityNameColor(spaceName),
"Username": terminal.EntityNameColor(cmd.config.Username()),
}))
space, err := cmd.spaceRepo.FindByName(spaceName)
if err != nil {
cmd.ui.Failed(err.Error())
}
if space.SpaceQuotaGuid != "" {
cmd.ui.Failed(T("This space already has an assigned space quota."))
}
quota, err := cmd.quotaRepo.FindByName(quotaName)
if err != nil {
cmd.ui.Failed(err.Error())
}
err = cmd.quotaRepo.AssociateSpaceWithQuota(space.Guid, quota.Guid)
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Ok()
}
开发者ID:Doebe,项目名称:workplace,代码行数:32,代码来源:set_space_quota.go
示例11: Execute
func (cmd *RenameService) Execute(c flags.FlagContext) {
newName := c.Args()[1]
serviceInstance := cmd.serviceInstanceReq.GetServiceInstance()
cmd.ui.Say(T("Renaming service {{.ServiceName}} to {{.NewServiceName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.CurrentUser}}...",
map[string]interface{}{
"ServiceName": terminal.EntityNameColor(serviceInstance.Name),
"NewServiceName": terminal.EntityNameColor(newName),
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
err := cmd.serviceRepo.RenameService(serviceInstance, newName)
if err != nil {
if httpError, ok := err.(errors.HttpError); ok && httpError.ErrorCode() == errors.SERVICE_INSTANCE_NAME_TAKEN {
cmd.ui.Failed(T("{{.ErrorDescription}}\nTIP: Use '{{.CFServicesCommand}}' to view all services in this org and space.",
map[string]interface{}{
"ErrorDescription": httpError.Error(),
"CFServicesCommand": cf.Name() + " " + "services",
}))
} else {
cmd.ui.Failed(err.Error())
}
}
cmd.ui.Ok()
}
开发者ID:Doebe,项目名称:workplace,代码行数:28,代码来源:rename_service.go
示例12: Execute
func (cmd *DeleteSpace) Execute(c flags.FlagContext) {
spaceName := c.Args()[0]
if !c.Bool("f") {
if !cmd.ui.ConfirmDelete(T("space"), spaceName) {
return
}
}
cmd.ui.Say(T("Deleting space {{.TargetSpace}} in org {{.TargetOrg}} as {{.CurrentUser}}...",
map[string]interface{}{
"TargetSpace": terminal.EntityNameColor(spaceName),
"TargetOrg": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
space := cmd.spaceReq.GetSpace()
apiErr := cmd.spaceRepo.Delete(space.Guid)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
if cmd.config.SpaceFields().Guid == space.Guid {
cmd.config.SetSpaceFields(models.SpaceFields{})
cmd.ui.Say(T("TIP: No space targeted, use '{{.CfTargetCommand}}' to target a space",
map[string]interface{}{"CfTargetCommand": cf.Name() + " target -s"}))
}
return
}
开发者ID:Doebe,项目名称:workplace,代码行数:34,代码来源:delete_space.go
示例13: Execute
func (cmd *UnsetSpaceQuota) Execute(c flags.FlagContext) {
spaceName := c.Args()[0]
quotaName := c.Args()[1]
space, apiErr := cmd.spaceRepo.FindByName(spaceName)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
quota, apiErr := cmd.quotaRepo.FindByName(quotaName)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Say(T("Unassigning space quota {{.QuotaName}} from space {{.SpaceName}} as {{.Username}}...",
map[string]interface{}{
"QuotaName": terminal.EntityNameColor(quota.Name),
"SpaceName": terminal.EntityNameColor(space.Name),
"Username": terminal.EntityNameColor(cmd.config.Username())}))
apiErr = cmd.quotaRepo.UnassignQuotaFromSpace(space.Guid, quota.Guid)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
}
开发者ID:Doebe,项目名称:workplace,代码行数:30,代码来源:unset_space_quota.go
示例14: Execute
func (cmd *DeleteUser) Execute(c flags.FlagContext) {
username := c.Args()[0]
force := c.Bool("f")
if !force && !cmd.ui.ConfirmDelete(T("user"), username) {
return
}
cmd.ui.Say(T("Deleting user {{.TargetUser}} as {{.CurrentUser}}...",
map[string]interface{}{
"TargetUser": terminal.EntityNameColor(username),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
user, apiErr := cmd.userRepo.FindByUsername(username)
switch apiErr.(type) {
case nil:
case *errors.ModelNotFoundError:
cmd.ui.Ok()
cmd.ui.Warn(T("User {{.TargetUser}} does not exist.", map[string]interface{}{"TargetUser": username}))
return
default:
cmd.ui.Failed(apiErr.Error())
return
}
apiErr = cmd.userRepo.Delete(user.Guid)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
}
开发者ID:Doebe,项目名称:workplace,代码行数:34,代码来源:delete_user.go
示例15: printer
func (cmd *OrgUsers) printer(c flags.FlagContext) userprint.UserPrinter {
var roles []string
if c.Bool("a") {
roles = []string{models.ORG_USER}
} else {
roles = []string{models.ORG_MANAGER, models.BILLING_MANAGER, models.ORG_AUDITOR}
}
if cmd.pluginCall {
return userprint.NewOrgUsersPluginPrinter(
cmd.pluginModel,
cmd.userLister(),
roles,
)
}
return &userprint.OrgUsersUiPrinter{
Ui: cmd.ui,
UserLister: cmd.userLister(),
Roles: roles,
RoleDisplayNames: map[string]string{
models.ORG_USER: T("USERS"),
models.ORG_MANAGER: T("ORG MANAGER"),
models.BILLING_MANAGER: T("BILLING MANAGER"),
models.ORG_AUDITOR: T("ORG AUDITOR"),
},
}
}
开发者ID:Doebe,项目名称:workplace,代码行数:27,代码来源:org_users.go
示例16: Execute
func (cmd *PluginUninstall) Execute(c flags.FlagContext) {
pluginName := c.Args()[0]
pluginNameMap := map[string]interface{}{"PluginName": pluginName}
cmd.ui.Say(fmt.Sprintf(T("Uninstalling plugin {{.PluginName}}...", pluginNameMap)))
plugins := cmd.config.Plugins()
if _, ok := plugins[pluginName]; !ok {
cmd.ui.Failed(fmt.Sprintf(T("Plugin name {{.PluginName}} does not exist", pluginNameMap)))
}
pluginMetadata := plugins[pluginName]
err := cmd.notifyPluginUninstalling(pluginMetadata)
if err != nil {
cmd.ui.Say("Error invoking plugin: " + err.Error() + ". Process to uninstall ...")
}
time.Sleep(500 * time.Millisecond) //prevent 'process being used' error in Windows
err = os.Remove(pluginMetadata.Location)
if err != nil {
cmd.ui.Warn("Error removing plugin binary: " + err.Error())
}
cmd.config.RemovePlugin(pluginName)
cmd.ui.Ok()
cmd.ui.Say(fmt.Sprintf(T("Plugin {{.PluginName}} successfully uninstalled.", pluginNameMap)))
}
开发者ID:Doebe,项目名称:workplace,代码行数:31,代码来源:uninstall_plugin.go
示例17: Execute
func (cmd *ListStack) Execute(c flags.FlagContext) {
stackName := c.Args()[0]
stack, apiErr := cmd.stacksRepo.FindByName(stackName)
if c.Bool("guid") {
cmd.ui.Say(stack.Guid)
} else {
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Say(T("Getting stack '{{.Stack}}' in org {{.OrganizationName}} / space {{.SpaceName}} as {{.Username}}...",
map[string]interface{}{"Stack": stackName,
"OrganizationName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"Username": terminal.EntityNameColor(cmd.config.Username())}))
cmd.ui.Ok()
cmd.ui.Say("")
table := terminal.NewTable(cmd.ui, []string{T("name"), T("description")})
table.Add(stack.Name, stack.Description)
table.Print()
}
}
开发者ID:Doebe,项目名称:workplace,代码行数:27,代码来源:stack.go
示例18: Execute
func (cmd *MapRoute) Execute(c flags.FlagContext) {
hostName := c.String("n")
domain := cmd.domainReq.GetDomain()
app := cmd.appReq.GetApplication()
route, apiErr := cmd.routeCreator.CreateRoute(hostName, domain, cmd.config.SpaceFields())
if apiErr != nil {
cmd.ui.Failed(T("Error resolving route:\n{{.Err}}", map[string]interface{}{"Err": apiErr.Error()}))
}
cmd.ui.Say(T("Adding route {{.URL}} to app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...",
map[string]interface{}{
"URL": terminal.EntityNameColor(route.URL()),
"AppName": terminal.EntityNameColor(app.Name),
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"Username": terminal.EntityNameColor(cmd.config.Username())}))
apiErr = cmd.routeRepo.Bind(route.Guid, app.Guid)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
}
开发者ID:Doebe,项目名称:workplace,代码行数:25,代码来源:map_route.go
示例19: Execute
func (cmd *ListRoutes) Execute(c flags.FlagContext) {
flag := c.Bool("orglevel")
if flag {
cmd.ui.Say(T("Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
map[string]interface{}{
"Username": terminal.EntityNameColor(cmd.config.Username()),
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
}))
} else {
cmd.ui.Say(T("Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
map[string]interface{}{
"Username": terminal.EntityNameColor(cmd.config.Username()),
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
}))
}
table := cmd.ui.Table([]string{T("space"), T("host"), T("domain"), T("apps"), T("service")})
noRoutes := true
var apiErr error
if flag {
apiErr = cmd.routeRepo.ListAllRoutes(func(route models.Route) bool {
noRoutes = false
appNames := []string{}
for _, app := range route.Apps {
appNames = append(appNames, app.Name)
}
table.Add(route.Space.Name, route.Host, route.Domain.Name, strings.Join(appNames, ","), route.ServiceInstance.Name)
return true
})
} else {
apiErr = cmd.routeRepo.ListRoutes(func(route models.Route) bool {
noRoutes = false
appNames := []string{}
for _, app := range route.Apps {
appNames = append(appNames, app.Name)
}
table.Add(route.Space.Name, route.Host, route.Domain.Name, strings.Join(appNames, ","), route.ServiceInstance.Name)
return true
})
}
table.Print()
if apiErr != nil {
cmd.ui.Failed(T("Failed fetching routes.\n{{.Err}}", map[string]interface{}{"Err": apiErr.Error()}))
return
}
if noRoutes {
cmd.ui.Say(T("No routes found"))
}
}
开发者ID:cf-routing,项目名称:cli,代码行数:60,代码来源:routes.go
示例20: Execute
func (cmd *PurgeServiceInstance) Execute(c flags.FlagContext) {
instanceName := c.Args()[0]
instance, err := cmd.serviceRepo.FindInstanceByName(instanceName)
if err != nil {
if _, ok := err.(*errors.ModelNotFoundError); ok {
cmd.ui.Warn(T("Service instance {{.InstanceName}} not found", map[string]interface{}{"InstanceName": instanceName}))
return
}
cmd.ui.Failed(err.Error())
}
force := c.Bool("f")
if !force {
cmd.ui.Warn(cmd.scaryWarningMessage())
confirmed := cmd.ui.Confirm(T("Really purge service instance {{.InstanceName}} from Cloud Foundry?",
map[string]interface{}{"InstanceName": instanceName},
))
if !confirmed {
return
}
}
cmd.ui.Say(T("Purging service {{.InstanceName}}...", map[string]interface{}{"InstanceName": instanceName}))
err = cmd.serviceRepo.PurgeServiceInstance(instance)
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Ok()
}
开发者ID:Doebe,项目名称:workplace,代码行数:33,代码来源:purge_service_instance.go
注:本文中的github.com/simonleung8/flags.FlagContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论