Beispiel #1
0
func selectSubdomainIfNeeded() {
	app, err := account.GetCurrentApp()
	fail.Handle(err)
	if app.HostingSubdomain == "" {
		selectSubdomain(app.AppID, true)
	}
}
Beispiel #2
0
func createCollection(name string, schema map[string]interface{}) {
	app, _ := account.GetCurrentApp()
	collection := account.Collection{
		CollectionName: name,
		AppID:          app.AppID,
		AccountID:      session.ReadAccountID(),
		Schema:         schema,
	}

	collection, err := account.SaveNewCollection(collection)
	if err != nil {
		term.Println(err.Error())
	} else {
		term.Printf("Collection %s created successfully!\n", collection.CollectionName)
		term.Section()
		showCollectionInfo(collection)
	}
}
Beispiel #3
0
func DoOpen(c *cli.Context) {
	useOptions(c)
	dest := c.Args().First()
	log.Debugf("Open destination: %s", dest)
	url := ""
	message := ""

	switch dest {

	default:
		fallthrough
	case "deployed":
		app, err := account.GetCurrentApp()
		if err != nil {
			message = "Sorry, could not find a deployed app to open."
		}
		url = "http://" + app.HostingSubdomain + ".appstax.io"
		break

	case "admin":
		url = "http://appstax.com/admin/#/dashboard"
		break

	case "local":
		url = "http://localhost:9000/"
		break
	}

	if url != "" {
		term.Printf("Opening %s in your browser.\n", url)
		err := open.Start(url)
		if err != nil {
			message = "Ooops! Something went wrong."
		}
	}

	if message != "" {
		term.Section()
		term.Println(message)
	}
}
Beispiel #4
0
func DoInfo(c *cli.Context) {
	useOptions(c)
	loginIfNeeded()
	if !config.Exists() {
		term.Println("No app configured in current directory. (Missing appstax.conf)")
	} else {
		app, err := account.GetCurrentApp()
		if err != nil {
			term.Println("You don't have access to the currently selected app")
		} else {
			term.Println("App name:    " + app.AppName)
			term.Println("Description: " + app.AppDescription)
			term.Println("App key:     " + app.AppKey)
			term.Println("Collections: " + strings.Join(app.CollectionNames(), ", "))
			term.Println("Hosting:     " + account.FormatHostingUrl(app))
			term.Section()
		}
	}
	user, err := account.GetUser()
	fail.Handle(err)
	term.Printf("Logged in as %s %s (%s)\n", user.FirstName, user.LastName, user.Email)
}