Repository: Shopify/themekit (go)

Issue:
"theme open" parameter to hide the preview bar
**Is your feature request related to a problem? Please describe.**
It disturbs me that I always have to manually append ?pb=0 when I use the "theme open" command.

**Describe the solution you'd like**
I want to enter "theme open --without-pb" and then it magically opens https://foo.myshopify.com?preview_theme_id=123456&pb=0 without the theme preview bar.

**Describe alternatives you've considered**
I think there is no alternative to such a good solution... ;-)

**Additional context**
Not needed.


Pull request description:
Hide PB on open
fixes #820 

Paired with @carmelal 

Adds `--hidepb` to `theme open` to automatically hide the preview bar.

### Warn Checklist
- [ ] This changes the interface and requires a Major/Minor version change.
- [x] I have :tophat:'d these changes by using the commands I changed by hand.
- [ ] I have added a dependancy to the project.
- [x] I have considered any potential impact on [node-themekit](https://github.com/Shopify/node-themekit)


Patch:
diff --git a/changelog.txt b/changelog.txt
index c7ab241..4d22a0e 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -5,6 +5,7 @@ v1.1.3
 - Set status error codes when errors occur for better scriptability (#826)
 - Added --live flag to get, download, configure to automatically set
 configuration to the published theme
+- Added --hidepb flag to hide preview bar (#829)
 
 v1.1.2 (Sep 29, 2020)
 =====================
diff --git a/cmd/open.go b/cmd/open.go
index 20278f2..2d7036f 100644
--- a/cmd/open.go
+++ b/cmd/open.go
@@ -29,6 +29,9 @@ url for your reference`,
 
 func preview(ctx *cmdutil.Ctx, run runFunc, runWith runWithFunc) error {
 	url := fmt.Sprintf("https://%s?preview_theme_id=%s", ctx.Env.Domain, ctx.Env.ThemeID)
+	if ctx.Flags.HidePreviewBar {
+		url += "&pb=0"
+	}
 	if ctx.Flags.Edit {
 		url = fmt.Sprintf("https://%s/admin/themes/%s/editor", ctx.Env.Domain, ctx.Env.ThemeID)
 	}
diff --git a/cmd/theme.go b/cmd/theme.go
index a53fad3..b8f5a7a 100644
--- a/cmd/theme.go
+++ b/cmd/theme.go
@@ -102,6 +102,7 @@ func init() {
 	openCmd.Flags().StringVarP(&flags.With, "browser", "b", "", "name of the browser to open the url. the name should match the name of browser on your system.")
 	getCmd.Flags().BoolVarP(&flags.List, "list", "l", false, "list available themes.")
 	deployCmd.Flags().BoolVarP(&flags.NoDelete, "nodelete", "n", false, "do not delete files on shopify during deploy.")
+	openCmd.Flags().BoolVar(&flags.HidePreviewBar, "hidepb", false, "run command with all environments")
 
 	getCmd.Flags().BoolVar(&flags.Live, "live", false, "will allow themekit to autofill the theme ID as the currently published theme ID")
 	downloadCmd.Flags().BoolVar(&flags.Live, "live", false, "will allow themekit to autofill the theme ID as the currently published theme ID")
diff --git a/docs/commands/index.md b/docs/commands/index.md
index 7eaf3cb..a794cb7 100644
--- a/docs/commands/index.md
+++ b/docs/commands/index.md
@@ -157,6 +157,7 @@ theme open --env=production # will open http://your-store.myshopify.com?preview_
 |`-a`|`--allenvs`| run command with all environments
 |`-b`|`--browser`| name of the browser to open the url, matching the name of browser on your system.
 |`-E`|`--edit   `| open the web editor for the theme.
+|    |`--hidepb `| hide preview bar when opening the the preview page
 
 ## Remove
 Remove will delete theme files both locally and on Shopify. Unlike the other file
diff --git a/src/cmdutil/util.go b/src/cmdutil/util.go
index 4ff7e55..e52adc8 100644
--- a/src/cmdutil/util.go
+++ b/src/cmdutil/util.go
@@ -56,6 +56,7 @@ type Flags struct {
 	NoDelete              bool
 	AllowLive             bool
 	Live                  bool
+	HidePreviewBar        bool
 }
 
 // Ctx is a specific context that a command will run in


Test patch:
diff --git a/cmd/open_test.go b/cmd/open_test.go
index e503f7a..1ffe0f9 100644
--- a/cmd/open_test.go
+++ b/cmd/open_test.go
@@ -19,6 +19,15 @@ func TestOpen(t *testing.T) {
 		return nil
 	}, rw))
 
+	ctx, _, _, _, _ = createTestCtx()
+	ctx.Env.Domain = "my.test.domain"
+	ctx.Env.ThemeID = "123"
+	ctx.Flags.HidePreviewBar = true
+	assert.Nil(t, preview(ctx, func(path string) error {
+		assert.Equal(t, path, "https://my.test.domain?preview_theme_id=123&pb=0")
+		return nil
+	}, rw))
+
 	ctx, _, _, _, _ = createTestCtx()
 	ctx.Env.Domain = "my.test.domain"
 	ctx.Env.ThemeID = "123"