Ejemplo n.º 1
0
func appRemoveAction(c *cli.Context) {
	listOfApps, err := apps.LinkedApps("")
	utils.CheckError(err)
	if len(listOfApps) == 0 {
		log.Fatal("没有关联任何应用")
	}

	answers := []wizard.Answer{}
	appToRemove := new(string)
	for _, app := range listOfApps {
		answers = append(answers, wizard.Answer{
			Content: fmt.Sprintf("%s - %s", app.AppName, app.AppID),
			Handler: func() {
				appToRemove = &app.AppName
			},
		})
	}

	wizard.Ask([]wizard.Question{
		{
			Content: "请选择要移除关联的应用:",
			Answers: answers,
		},
	})

	log.Println("移除关联的应用:", *appToRemove)
	apps.RemoveApp("", *appToRemove)
}
Ejemplo n.º 2
0
func selectRuntime() int {
	runtimeType := 0

	wizard.Ask([]wizard.Question{
		{
			Content: "请选择项目语言:",
			Answers: []wizard.Answer{
				{
					Content: "Python",
					Handler: func() {
						runtimeType = boilerplate.Python
					},
				}, {
					Content: "Node.js",
					Handler: func() {
						runtimeType = boilerplate.NodeJS
					},
				},
				// {
				// 	Content: "PHP",
				// 	Handler: func() {
				// 		runtimeType = runtimePHP
				// 	},
				// },
			},
		},
	})
	return runtimeType
}
Ejemplo n.º 3
0
func getAppInfoFromServer(appID string) (*AppInfo, error) {
	masterKey := new(string)
	wizard.Ask([]wizard.Question{
		{
			Content: "请输入应用的 Master Key:",
			Input: &wizard.Input{
				Hidden: true,
				Result: masterKey,
			},
		},
	})

	client := api.NewKeyAuthClient(appID, *masterKey)

	content, err := client.AppDetail()
	if err != nil {
		return nil, err
	}

	return &AppInfo{
		AppID:     appID,
		AppKey:    content.Get("app_key").MustString(),
		MasterKey: *masterKey,
	}, nil
}
Ejemplo n.º 4
0
func inputAccountInfo() (string, string) {
	var email = new(string)
	var password = new(string)
	wizard.Ask([]wizard.Question{
		{
			Content: "请输入您的邮箱:",
			Input: &wizard.Input{
				Result: email,
				Hidden: false,
			},
		},
		{
			Content: "请输入您的密码:",
			Input: &wizard.Input{
				Result: password,
				Hidden: true,
			},
		},
	})
	return *email, *password
}
Ejemplo n.º 5
0
func selectApp(appList []interface{}) map[string]interface{} {
	var selectedApp map[string]interface{}
	question := wizard.Question{
		Content: "请选择 APP",
		Answers: []wizard.Answer{},
	}
	for _, _app := range appList {
		app := _app.(map[string]interface{})
		answer := wizard.Answer{
			Content: app["app_name"].(string),
		}
		// for scope problem
		func(app map[string]interface{}) {
			answer.Handler = func() {
				selectedApp = app
			}
		}(app)
		question.Answers = append(question.Answers, answer)
	}
	wizard.Ask([]wizard.Question{question})
	return selectedApp
}
Ejemplo n.º 6
0
func appAddAction(c *cli.Context) {
	var appName, appID string
	wizard.Ask([]wizard.Question{
		{
			Content: "请输入应用名:",
			Input: &wizard.Input{
				Hidden: false,
				Result: &appName,
			},
		},
		{
			Content: "请输入应用 appID:",
			Input: &wizard.Input{
				Hidden: false,
				Result: &appID,
			},
		},
	})

	utils.CheckError(apps.AddApp("", appName, appID))
	utils.CheckError(apps.SwitchApp("", appName))
	log.Println("已切换至应用:" + appName)
}