From 52e7b7cc86c26947abc4395467557458d195446c Mon Sep 17 00:00:00 2001 From: ttran112 Date: Mon, 31 May 2021 14:08:15 -0700 Subject: [PATCH] added the message to help the user navigate github --- pkg/cmd/browse/browse.go | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/browse/browse.go b/pkg/cmd/browse/browse.go index c51fe4396..f8f6e0228 100644 --- a/pkg/cmd/browse/browse.go +++ b/pkg/cmd/browse/browse.go @@ -6,12 +6,12 @@ import ( "strconv" "strings" + "github.com/MakeNowJust/heredoc" + "github.com/cli/cli/api" "github.com/cli/cli/internal/ghrepo" "github.com/cli/cli/pkg/cmdutil" "github.com/cli/cli/pkg/iostreams" "github.com/spf13/cobra" - - "github.com/cli/cli/api" ) type browser interface { @@ -60,6 +60,29 @@ func NewCmdBrowse(f *cmdutil.Factory) *cobra.Command { Use: "browse", // necessary!!! This is the cmd that gets passed on the prompt Args: cobra.RangeArgs(0, 2), // make sure only one arg at most is passed + Example: heredoc.Doc(` + $ gh browse + #=> Opens repository in browser + + $ gh browse 217 + #=> Opens issue or pull request 217 + + $ gh browse --settings + #=> Opens repository settings in browser + + $ gh browse src/fileName:312 --branch main + #=> Opens src/fileName at line 312 in main branch + `), + + Annotations: map[string]string{ + "IsCore": "true", + "help:arguments": heredoc.Doc(` + A browse location can be supplied as an argument in any of the following formats: + - by number, e.g. "123"; or + - by file or branch name, e.g. "main.java" or "trunk". + `), + }, + Run: func(cmd *cobra.Command, args []string) { if len(args) > 1 {