-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.go
42 lines (34 loc) · 1.26 KB
/
create.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"github.com/BitBalloon/bitballoon-go"
"github.com/spf13/cobra"
"log"
)
var createCmd = &cobra.Command{
Use: "create",
Short: "create a new BitBalloon site",
Long: "creates a new site and returns an ID you can deploy to",
}
var siteName, customDomain, password, notificationEmail string
func init() {
createCmd.Run = create
createCmd.Flags().StringVarP(&siteName, "name", "n", "", "Name of the site (must be a valid subdomain: <name>.bitballoon.com)")
createCmd.Flags().StringVarP(&customDomain, "domain", "d", "", "Custom domain for the site (only works for premium sites)")
createCmd.Flags().StringVarP(&password, "password", "p", "", "Password for the site")
createCmd.Flags().StringVarP(¬ificationEmail, "email", "e", "", "Notification email for form submissions (only works for premium sites)")
}
func create(cmd *cobra.Command, args []string) {
client := newClient()
site, _, err := client.Sites.Create(&bitballoon.SiteAttributes{
Name: siteName,
CustomDomain: customDomain,
Password: password,
NotificationEmail: notificationEmail,
})
if err != nil {
log.Fatalf("Error creating site: %v", err)
}
log.Println("Site created")
log.Printf("URL: %v", site.Url)
log.Printf("ID: %v", site.Id)
}