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)
}
Example #2
0
func deployAction(*cli.Context) {
	_apps, err := apps.LinkedApps(".")
	utils.CheckError(err)
	if len(_apps) == 0 {
		log.Fatalln("没有关联任何 app,请使用 lean app add 来关联应用。")
	}

	// TODO: specific app
	app := _apps[0]

	appInfo, err := apps.GetAppInfo(app.AppID)
	utils.CheckError(err)

	groupName, err := deployGroupName(appInfo)
	utils.CheckError(err)

	if groupName == "staging" {
		log.Println("准备部署应用到预备环境")
	} else {
		log.Println("准备部署应用到生产环境: " + groupName)
	}

	if isDeployFromGit {
		deployFromGit(appInfo, groupName)
	} else {
		deployFromLocal(appInfo, groupName)
	}
}
Example #3
0
func appListAction(c *cli.Context) {
	appList, err := apps.LinkedApps("")
	utils.CheckError(err)

	currentAppName, err := apps.CurrentAppName("")
	utils.CheckError(err)

	for _, app := range appList {
		if currentAppName == app.AppName {
			fmt.Printf("* %s - %s \r\n", app.AppName, app.AppID)
		} else {
			fmt.Printf("  %s - %s \r\n", app.AppName, app.AppID)
		}
	}
}