-
Notifications
You must be signed in to change notification settings - Fork 19
/
runstatus_create.go
47 lines (39 loc) · 964 Bytes
/
runstatus_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
43
44
45
46
47
package cmd
import (
"fmt"
"github.com/exoscale/egoscale"
"github.com/spf13/cobra"
)
// runstatusCreateCmd represents the create command
var runstatusCreateCmd = &cobra.Command{
Use: "create <page name>+",
Short: "Create Runstat.us page",
Aliases: gCreateAlias,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return cmd.Usage()
}
dark, err := cmd.Flags().GetBool("dark")
if err != nil {
return err
}
for _, arg := range args {
result, err := csRunstatus.CreateRunstatusPage(gContext, egoscale.RunstatusPage{
Name: arg,
Subdomain: arg,
DarkTheme: dark,
})
if err != nil {
return err
}
if !gQuiet {
fmt.Printf("Runstat.us page %q created:\n - %s\n", result.Subdomain, result.PublicURL)
}
}
return nil
},
}
func init() {
runstatusCmd.AddCommand(runstatusCreateCmd)
runstatusCreateCmd.Flags().BoolP("dark", "d", false, "Enable status page dark mode")
}