Repository: cli/cli
File: pkg/cmd/browse/browse.go (Go)

Code before:
	SelectorArg string

	Branch          string
	Commit          string
	ProjectsFlag    bool
	ReleasesFlag    bool
	SettingsFlag    bool
	WikiFlag        bool
	NoBrowserFlag   bool
	HasRepoOverride bool
}

func NewCmdBrowse(f *cmdutil.Factory, runF func(*BrowseOptions) error) *cobra.Command {
	opts := &BrowseOptions{
		Browser:    f.Browser,
		HttpClient: f.HttpClient,
		IO:         f.IOStreams,
		PathFromRepoRoot: func() string {
			return f.GitClient.PathFromRoot(context.Background())
		},
		GitClient: &localGitClient{client: f.GitClient},
	}

	cmd := &cobra.Command{
		Long:  "Open the GitHub repository, path inside it, commit, issue or pull request in the web browser.",
		Short: "Open the repository, path inside it, issue or PR in the browser",
		Use:   "browse [<number> | <path> | <commit-SHA>]",
		Args:  cobra.MaximumNArgs(1),
		Example: heredoc.Doc(`
			$ gh browse
			#=> Open the home page of the current repository

			$ gh browse script/
			#=> Open the script directory of the current repository

			$ gh browse 217
			#=> Open issue or pull request 217

			$ gh browse 77507cd94ccafcf568f8560cfecde965fcfa63
			#=> Open commit page

			$ gh browse --settings
			#=> Open repository settings

			$ gh browse main.go:312
			#=> Open main.go at line 312

			$ gh browse main.go --branch bug-fix
			#=> Open main.go with the repository at head of bug-fix branch

			$ gh browse main.go --commit=77507cd94ccafcf568f8560cfecde965fcfa63

Review comment (suggestion):
**Is there any reason we shouldn't bring this more in line with other commands with a longer-`heredoc` `Long`?**

Like many of our other commands, I think the `Long` field should be expanded into the same multi line format we use elsewhere, allowing more content to be captured in a readable way.

For example:

https://github.com/cli/cli/blob/d60e5ffba335281439d95749abb6f4c3b94fabdc/pkg/cmd/api/api.go#L72-L104

**I'm not sold on the actual content below, but I think this would be easier to understand if it was reformatted**

```suggestion
		Short: "Open repositories, issues, pull requests, and more in the browser",
		Long:  heredoc.Doc(`
			Transition from the terminal to the web browser to view and interact with:

			- issues
			- pull requests
			- repository content
			- repository profile
			- repository settings
		`),
```

Code after:
	SelectorArg string

	Branch          string
	Commit          string
	ProjectsFlag    bool
	ReleasesFlag    bool
	SettingsFlag    bool
	WikiFlag        bool
	NoBrowserFlag   bool
	HasRepoOverride bool
}

func NewCmdBrowse(f *cmdutil.Factory, runF func(*BrowseOptions) error) *cobra.Command {
	opts := &BrowseOptions{
		Browser:    f.Browser,
		HttpClient: f.HttpClient,
		IO:         f.IOStreams,
		PathFromRepoRoot: func() string {
			return f.GitClient.PathFromRoot(context.Background())
		},
		GitClient: &localGitClient{client: f.GitClient},
	}

	cmd := &cobra.Command{
		Short: "Open repositories, issues, pull requests, and more in the browser",
		Long: heredoc.Doc(`
			Transition from the terminal to the web browser to view and interact with:

			- Issues
			- Pull requests
			- Repository content
			- Repository home page
			- Repository settings
		`),
		Use:  "browse [<number> | <path> | <commit-SHA>]",
		Args: cobra.MaximumNArgs(1),
		Example: heredoc.Doc(`
			$ gh browse
			#=> Open the home page of the current repository

			$ gh browse script/
			#=> Open the script directory of the current repository

			$ gh browse 217
			#=> Open issue or pull request 217

			$ gh browse 77507cd94ccafcf568f8560cfecde965fcfa63
			#=> Open commit page

			$ gh browse --settings
			#=> Open repository settings