@@ -25,6 +25,7 @@ type ViewOptions struct {
2525
2626 RepoArg string
2727 Web bool
28+ Branch string
2829}
2930
3031func NewCmdView (f * cmdutil.Factory , runF func (* ViewOptions ) error ) * cobra.Command {
@@ -41,7 +42,9 @@ func NewCmdView(f *cmdutil.Factory, runF func(*ViewOptions) error) *cobra.Comman
4142
4243With no argument, the repository for the current directory is displayed.
4344
44- With '--web', open the repository in a web browser instead.` ,
45+ With '--web', open the repository in a web browser instead.
46+
47+ With '--branch', view a specific branch of the repository.` ,
4548 Args : cobra .MaximumNArgs (1 ),
4649 RunE : func (c * cobra.Command , args []string ) error {
4750 if len (args ) > 0 {
@@ -55,6 +58,7 @@ With '--web', open the repository in a web browser instead.`,
5558 }
5659
5760 cmd .Flags ().BoolVarP (& opts .Web , "web" , "w" , false , "Open a repository in the browser" )
61+ cmd .Flags ().StringVarP (& opts .Branch , "branch" , "b" , "" , "View a specific branch of the repository" )
5862
5963 return cmd
6064}
@@ -104,7 +108,7 @@ func viewRun(opts *ViewOptions) error {
104108
105109 fullName := ghrepo .FullName (toView )
106110
107- readme , err := RepositoryReadme (httpClient , toView )
111+ readme , err := RepositoryReadme (httpClient , toView , opts . Branch )
108112 if err != nil && err != NotFoundError {
109113 return err
110114 }
0 commit comments