зеркало из https://github.com/mislav/hub.git
Make subpage an optional argument for gh#browse
This commit is contained in:
Родитель
0d64c3a945
Коммит
1089f338b3
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
var cmdBrowse = &Command{
|
||||
Run: browse,
|
||||
Usage: "browse [-u USER] [-r REPOSITORY] [-p SUBPAGE]",
|
||||
Usage: "browse [-u USER] [-r REPOSITORY] [SUBPAGE]",
|
||||
Short: "Open a GitHub page in the default browser",
|
||||
Long: `Open repository's GitHub page in the system's default web browser using
|
||||
open(1) or the BROWSER env variable. If the repository isn't specified,
|
||||
|
@ -17,22 +17,26 @@ one of "wiki", "commits", "issues" or other (the default is "tree").
|
|||
`,
|
||||
}
|
||||
|
||||
var flagBrowseUser, flagBrowseRepo, flagBrowseSubpage string
|
||||
var flagBrowseUser, flagBrowseRepo string
|
||||
|
||||
func init() {
|
||||
cmdBrowse.Flag.StringVar(&flagBrowseUser, "u", "", "USER")
|
||||
cmdBrowse.Flag.StringVar(&flagBrowseRepo, "r", "", "REPOSITORY")
|
||||
cmdBrowse.Flag.StringVar(&flagBrowseSubpage, "p", "tree", "SUBPAGE")
|
||||
}
|
||||
|
||||
func browse(command *Command, args []string) {
|
||||
project := github.CurrentProject()
|
||||
if flagBrowseSubpage == "tree" || flagBrowseSubpage == "commits" {
|
||||
repo := project.LocalRepo()
|
||||
flagBrowseSubpage = utils.ConcatPaths(flagBrowseSubpage, repo.Head)
|
||||
subpage := "tree"
|
||||
if len(args) > 0 {
|
||||
subpage = args[0]
|
||||
}
|
||||
|
||||
url := project.WebUrl(flagBrowseRepo, flagBrowseUser, flagBrowseSubpage)
|
||||
project := github.CurrentProject()
|
||||
if subpage == "tree" || subpage == "commits" {
|
||||
repo := project.LocalRepo()
|
||||
subpage = utils.ConcatPaths(subpage, repo.Head)
|
||||
}
|
||||
|
||||
url := project.WebUrl(flagBrowseRepo, flagBrowseUser, subpage)
|
||||
err := browserCommand(url)
|
||||
utils.Check(err)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче