Skip to content

Commit

Permalink
Merge pull request #72 from shopetan/github/implement_cmd_of_repo_in_…
Browse files Browse the repository at this point in the history
…order_to_move_quickly

Implement cmd of github repository in order to move quickly
  • Loading branch information
KeisukeYamashita authored Dec 17, 2019
2 parents 2f2b4ae + 50808e2 commit 28f2c4b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 10 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,11 @@ $ biko github [product] [flag(s)]
$ biko gh [product] [flag(s)]
```

| Product | What | Command | Flags(Optional) |
| :----: | :----: | :----: | :----: |
| Dashboard | Open github Dashboard | `dashboard`, `db` | `--org` |
| Trending | Open github Treinding | `trending`, `t` | `--language, -l`, `--since, -s` |
| Product | What | Command | Flags(Optional) |
| :----: | :----: | :----: | :----: |
| Dashboard | Open github Dashboard | `dashboard`, `db` | `--org` |
| Trending | Open github Treinding | `trending`, `t` | `--language, -l`, `--since, -s` |
| Repository | Open github Repository | `repository`, `r` | `--org`, `--name, -n` |

### Google

Expand Down
29 changes: 29 additions & 0 deletions cli/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func newGithubCmd() cli.Command {
Subcommands: []cli.Command{
newGithubDashboardCmd(),
newGithubTrendingCmd(),
newGithubRepositoryCmd(),
},
}
}
Expand Down Expand Up @@ -86,3 +87,31 @@ func newGithubTrendingCmd() cli.Command {
}

}

func newGithubRepositoryCmd() cli.Command {
return cli.Command{
Name: "repository",
Aliases: []string{"r"},
Usage: "Open the repository page",
Flags: []cli.Flag{
cli.StringFlag{
Name: "org",
Usage: "Organization to open",
},
cli.StringFlag{
Name: "users, u",
Usage: "User page to open",
},
cli.StringFlag{
Name: "name, n",
Usage: "Name of repository that depend on Organization",
},
},
Action: func(c *cli.Context) error {

github := &gh.Provider{}
return browser.Open(c, github)
},
}

}
31 changes: 25 additions & 6 deletions providers/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,45 @@ func (p *Provider) GetTargetURL() (string, error) {
func (p *Provider) addProductPath(product string) {
switch product {
case "dashboard":
var org string
if org = p.Ctx.String("org"); org != "" {
if org := p.Ctx.String("org"); org != "" {
p.join(fmt.Sprintf("orgs/%s/dashboard", org))
return
}
p.URL = p.baseURL
return
case "trending":
p.join("trending")
var since string
if since = p.Ctx.String("since"); since != "" {
if since := p.Ctx.String("since"); since != "" {
param := url.Values{}
param.Add("since", since)
p.URL.RawQuery = param.Encode()
}
var language string
if language = p.Ctx.String("language"); language != "" {
if language := p.Ctx.String("language"); language != "" {
p.join(language)
return
}
case "repository":

users := p.Ctx.String("users")
org := p.Ctx.String("org")
if users != "" && org != "" {
p.URL = p.baseURL
return
}
if users != "" {
p.join(users)
} else {
p.join(org)
}

if name := p.Ctx.String("name"); name != "" {
if users != "" || org != "" {
p.join(name)
}
return
}
p.URL = p.baseURL
return
default:
p.URL = p.baseURL
}
Expand Down

0 comments on commit 28f2c4b

Please sign in to comment.