本文整理匯總了Golang中code/cloudfoundry/org/cli/cf/cmd.Main函數的典型用法代碼示例。如果您正苦於以下問題:Golang Main函數的具體用法?Golang Main怎麽用?Golang Main使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Main函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Execute
func (cmd *ApiCommand) Execute(args []string) error {
if cmd.Config.Experimental() == false {
oldCmd.Main(os.Getenv("CF_TRACE"), os.Args)
return nil
}
cmd.UI.DisplayText("This command is in EXPERIMENTAL stage and may change without notice")
cmd.UI.DisplayNewline()
if cmd.Unset {
return cmd.ClearTarget()
}
if cmd.OptionalArgs.URL != "" {
err := cmd.SetAPI()
if err != nil {
return err
}
}
if cmd.Config.Target() == "" {
cmd.UI.DisplayText("No api endpoint set. Use '{{.Name}}' to set an endpoint", map[string]interface{}{
"Name": "cf api",
})
return nil
}
return DisplayCurrentTargetInformation(cmd.Config, cmd.UI)
}
示例2: Execute
func (cmd UnbindServiceCommand) Execute(args []string) error {
if cmd.Config.Experimental() == false {
oldCmd.Main(os.Getenv("CF_TRACE"), os.Args)
return nil
}
cmd.UI.DisplayText("This command is in EXPERIMENTAL stage and may change without notice")
cmd.UI.DisplayNewline()
err := common.CheckTarget(cmd.Config, true, true)
if err != nil {
return err
}
space := cmd.Config.TargetedSpace()
user, err := cmd.Config.CurrentUser()
if err != nil {
return err
}
cmd.UI.DisplayHeaderFlavorText("Unbinding app {{.AppName}} from service {{.ServiceName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.CurrentUser}}...", map[string]interface{}{
"AppName": cmd.RequiredArgs.AppName,
"ServiceName": cmd.RequiredArgs.ServiceInstanceName,
"OrgName": cmd.Config.TargetedOrganization().Name,
"SpaceName": space.Name,
"CurrentUser": user.Name,
})
warnings, err := cmd.Actor.UnbindServiceBySpace(cmd.RequiredArgs.AppName, cmd.RequiredArgs.ServiceInstanceName, space.GUID)
cmd.UI.DisplayWarnings(warnings)
if err != nil {
if _, ok := err.(v2actions.ServiceBindingNotFoundError); ok {
cmd.UI.DisplayWarning("Binding between {{.InstanceName}} and {{.AppName}} did not exist", map[string]interface{}{
"AppName": cmd.RequiredArgs.AppName,
"InstanceName": cmd.RequiredArgs.ServiceInstanceName,
})
} else {
return common.HandleError(err)
}
}
cmd.UI.DisplayOK()
return nil
}
示例3: Execute
func (_ RestartAppInstanceCommand) Execute(args []string) error {
cmd.Main(os.Getenv("CF_TRACE"), os.Args)
return nil
}
示例4: Execute
func (_ UnsharePrivateDomainCommand) Execute(args []string) error {
cmd.Main(os.Getenv("CF_TRACE"), os.Args)
return nil
}
示例5: Execute
func (_ RunningEnvironmentVariableGroupCommand) Execute(args []string) error {
cmd.Main(os.Getenv("CF_TRACE"), os.Args)
return nil
}
示例6: Execute
func (_ UnsetOrgRoleCommand) Execute(args []string) error {
cmd.Main(os.Getenv("CF_TRACE"), os.Args)
return nil
}
示例7: Execute
func (_ SpaceSSHAllowedCommand) Execute(args []string) error {
cmd.Main(os.Getenv("CF_TRACE"), os.Args)
return nil
}
示例8: Execute
func (_ DeleteSpaceQuotaCommand) Execute(args []string) error {
cmd.Main(os.Getenv("CF_TRACE"), os.Args)
return nil
}
示例9: Execute
func (_ RemovePluginRepoCommand) Execute(args []string) error {
cmd.Main(os.Getenv("CF_TRACE"), os.Args)
return nil
}
示例10: Execute
func (_ RouterGroupsCommand) Execute(args []string) error {
cmd.Main(os.Getenv("CF_TRACE"), os.Args)
return nil
}
示例11: Execute
func (_ CreateAppManifestCommand) Execute(args []string) error {
cmd.Main(os.Getenv("CF_TRACE"), os.Args)
return nil
}
示例12: Execute
func (_ DisableServiceAccessCommand) Execute(args []string) error {
cmd.Main(os.Getenv("CF_TRACE"), os.Args)
return nil
}
示例13: Execute
func (_ InstallPluginCommand) Execute(args []string) error {
cmd.Main(os.Getenv("CF_TRACE"), os.Args)
return nil
}
示例14: parse
func parse(args []string) {
parser := flags.NewParser(&v2.Commands, flags.HelpFlag)
parser.CommandHandler = executionWrapper
extraArgs, err := parser.ParseArgs(args)
if err == nil {
return
}
if flagErr, ok := err.(*flags.Error); ok {
switch flagErr.Type {
case flags.ErrHelp, flags.ErrUnknownFlag, flags.ErrExpectedArgument:
_, found := reflect.TypeOf(v2.Commands).FieldByNameFunc(
func(fieldName string) bool {
field, _ := reflect.TypeOf(v2.Commands).FieldByName(fieldName)
return parser.Active != nil && parser.Active.Name == field.Tag.Get("command")
},
)
if found && flagErr.Type == flags.ErrUnknownFlag && parser.Active.Name == "set-env" {
newArgs := []string{}
for _, arg := range args {
if arg[0] == '-' {
newArgs = append(newArgs, fmt.Sprintf("%s%s", v2.WorkAroundPrefix, arg))
} else {
newArgs = append(newArgs, arg)
}
}
parse(newArgs)
return
}
if flagErr.Type == flags.ErrUnknownFlag || flagErr.Type == flags.ErrExpectedArgument {
fmt.Fprintf(os.Stderr, "Incorrect Usage: %s\n\n", flagErr.Error())
}
if found {
parse([]string{"help", parser.Active.Name})
} else {
switch len(extraArgs) {
case 0:
parse([]string{"help"})
case 1:
if !isOption(extraArgs[0]) || (len(args) > 1 && extraArgs[0] == "-a") {
parse([]string{"help", extraArgs[0]})
} else {
parse([]string{"help"})
}
default:
if isCommand(extraArgs[0]) {
parse([]string{"help", extraArgs[0]})
} else {
parse(extraArgs[1:])
}
}
}
if flagErr.Type == flags.ErrUnknownFlag || flagErr.Type == flags.ErrExpectedArgument {
os.Exit(1)
}
case flags.ErrRequired:
fmt.Fprintf(os.Stderr, "Incorrect Usage: %s\n\n", flagErr.Error())
parse([]string{"help", args[0]})
os.Exit(1)
case flags.ErrUnknownCommand:
cmd.Main(os.Getenv("CF_TRACE"), os.Args)
case flags.ErrCommandRequired:
if v2.Commands.VerboseOrVersion {
parse([]string{"version"})
} else {
parse([]string{"help"})
}
default:
fmt.Fprintf(os.Stderr, "Unexpected flag error\ntype: %s\nmessage: %s\n", flagErr.Type, flagErr.Error())
}
} else if err == ErrFailed {
os.Exit(1)
} else {
fmt.Fprintf(os.Stderr, "Unexpected error: %s\n", err.Error())
os.Exit(1)
}
}
示例15: Execute
func (_ SetEnvCommand) Execute(args []string) error {
//TODO: Be sure to sanitize the WorkAroundPrefix
cmd.Main(os.Getenv("CF_TRACE"), os.Args)
return nil
}