-
Notifications
You must be signed in to change notification settings - Fork 375
/
open.go
39 lines (32 loc) · 847 Bytes
/
open.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
package cmd
import (
"fmt"
"sync"
"github.com/skratchdot/open-golang/open"
"github.com/spf13/cobra"
"github.com/Shopify/themekit/kit"
)
var openCmd = &cobra.Command{
Use: "open",
Short: "Open the preview for your store.",
Long: `Open will open the preview page in your browser as well as print out
url for your reference`,
RunE: forEachClient(preview),
}
func preview(client kit.ThemeClient, filenames []string, wg *sync.WaitGroup) {
defer wg.Done()
previewURL := fmt.Sprintf("https://%s?preview_theme_id=%s",
client.Config.Domain,
client.Config.ThemeID)
if verbose {
kit.Printf("[%s] opening %s",
kit.GreenText(client.Config.Environment),
kit.GreenText(previewURL))
}
err := open.Run(previewURL)
if err != nil {
kit.LogErrorf("[%s] %s",
kit.GreenText(client.Config.Environment),
kit.RedText(err))
}
}