diff --git a/pkg/cmd/browse/browse.go b/pkg/cmd/browse/browse.go index ceac582e7..c562cba2a 100644 --- a/pkg/cmd/browse/browse.go +++ b/pkg/cmd/browse/browse.go @@ -86,21 +86,16 @@ func openInBrowser(cmd *cobra.Command, opts *BrowseOptions) { repoUrl := ghrepo.GenerateRepoURL(baseRepo, "") parseArgs(opts) - if opts.SelectorArg == "" { + if !hasArgs(opts) { // handle flags without args if opts.ProjectsFlag { repoUrl += "/projects" - printExit(exitSuccess, cmd, opts, repoUrl) } else if opts.SettingsFlag { repoUrl += "/settings" - printExit(exitSuccess, cmd, opts, repoUrl) } else if opts.WikiFlag { repoUrl += "/wiki" - printExit(exitSuccess, cmd, opts, repoUrl) - } else if getFlagAmount(cmd) == 0 { - printExit(exitSuccess, cmd, opts, repoUrl) } - opts.Browser.Browse(repoUrl) + printExit(exitSuccess, cmd, opts, repoUrl) return } @@ -144,6 +139,10 @@ func printExit(errorCode exitCode, cmd *cobra.Command, opts *BrowseOptions, url } +func hasArgs(opts *BrowseOptions) bool { + return opts.SelectorArg != "" +} + func getFlagAmount(cmd *cobra.Command) int { return cmd.Flags().NFlag() }