-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6864f5d
Showing
9 changed files
with
683 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
### Go ### | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
### Go Patch ### | ||
/vendor/ | ||
/Godeps/ | ||
|
||
stars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# This is an example goreleaser.yaml file with some sane defaults. | ||
# Make sure to check the documentation at http://goreleaser.com | ||
builds: | ||
- env: | ||
- GO111MODULE=on | ||
- CGO_ENABLED=0 | ||
archive: | ||
replacements: | ||
darwin: Darwin | ||
linux: Linux | ||
windows: Windows | ||
386: i386 | ||
amd64: x86_64 | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ .Tag }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 George Kontridze | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# stars | ||
|
||
A command-line interface to your GitHub stars | ||
|
||
## Development | ||
|
||
```bash | ||
git clone [email protected]:gkze/stars-go.git | ||
cd stars-go | ||
go build # need Golang 1.11+ | ||
``` | ||
|
||
## Installation | ||
|
||
Binaries are available on the releases page. You can also install it easily with: | ||
|
||
```bash | ||
go get -u github.com/gkze/stars | ||
``` | ||
|
||
You also need a `~/.netrc` with a personal access token configured: | ||
|
||
```bash | ||
$ cat ~/.netrc | ||
machine api.github.com | ||
login gkze | ||
password [your github token here] | ||
``` | ||
|
||
Usage: | ||
|
||
```bash | ||
$ stars | ||
NAME: | ||
stars - Command-line interface to YOUR GitHub stars | ||
|
||
USAGE: | ||
stars [global options] command [command options] [arguments...] | ||
|
||
VERSION: | ||
0.0.0 | ||
|
||
COMMANDS: | ||
save Save all stars | ||
list-topics list all topics of starred projects | ||
random Browse random stars | ||
clear Clear local stars cache | ||
cleanup Clean up old stars | ||
help, h Shows a list of commands or help for one command | ||
|
||
GLOBAL OPTIONS: | ||
--help, -h show help | ||
--version, -v print the version | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module github.com/gkze/stars | ||
|
||
require ( | ||
github.com/DataDog/zstd v1.3.4 // indirect | ||
github.com/Sereal/Sereal v0.0.0-20180905114147-563b78806e28 // indirect | ||
github.com/asdine/storm v2.1.2+incompatible | ||
github.com/boltdb/bolt v1.3.1 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/dickeyxxx/netrc v0.0.0-20180207092346-e1a19c977509 // indirect | ||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect | ||
github.com/google/go-github v17.0.0+incompatible | ||
github.com/jdxcode/netrc v0.0.0-20180207092346-e1a19c977509 | ||
github.com/kr/pretty v0.1.0 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/stretchr/testify v1.2.2 // indirect | ||
github.com/urfave/cli v1.20.0 | ||
github.com/vmihailenco/msgpack v4.0.0+incompatible // indirect | ||
go.etcd.io/bbolt v1.3.0 // indirect | ||
golang.org/x/net v0.0.0-20180921000356-2f5d2388922f // indirect | ||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be | ||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect | ||
golang.org/x/sys v0.0.0-20180921163948-d47a0f339242 // indirect | ||
google.golang.org/appengine v1.2.0 // indirect | ||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect | ||
) | ||
|
||
replace github.com/google/go-github => github.com/google/go-github/v18 v18.1.1-0.20180920013327-07716bad7a0c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
github.com/DataDog/zstd v1.3.4 h1:LAGHkXuvC6yky+C2CUG2tD7w8QlrUwpue8XwIh0X4AY= | ||
github.com/DataDog/zstd v1.3.4/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= | ||
github.com/Sereal/Sereal v0.0.0-20180905114147-563b78806e28 h1:KjLSBawWQq6I0p9VRX8RtHIuttTYvUCGfMgNoBBFxYs= | ||
github.com/Sereal/Sereal v0.0.0-20180905114147-563b78806e28/go.mod h1:D0JMgToj/WdxCgd30Kc1UcA9E+WdZoJqeVOuYW7iTBM= | ||
github.com/asdine/storm v2.1.2+incompatible h1:dczuIkyqwY2LrtXPz8ixMrU/OFgZp71kbKTHGrXYt/Q= | ||
github.com/asdine/storm v2.1.2+incompatible/go.mod h1:RarYDc9hq1UPLImuiXK3BIWPJLdIygvV3PsInK0FbVQ= | ||
github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4= | ||
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/dickeyxxx/netrc v0.0.0-20180207092346-e1a19c977509 h1:WF2KfMRjy3IQj8L2rlhqJC3RysGz92LuzbgjqdkS2WI= | ||
github.com/dickeyxxx/netrc v0.0.0-20180207092346-e1a19c977509/go.mod h1:yJi2ErNJXXF67mkADCp1kk8AMBFiX48CwUWnsjpCpII= | ||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= | ||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= | ||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w= | ||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= | ||
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY= | ||
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= | ||
github.com/google/go-github/v18 v18.1.1-0.20180920013327-07716bad7a0c h1:p+V16Anf7PTAUHoIizdalt5kFArNheY09sZH3Fr4gK4= | ||
github.com/google/go-github/v18 v18.1.1-0.20180920013327-07716bad7a0c/go.mod h1:Bf4Ut1RTeH0WuX7Z4Zf7N+qp/YqgcFOxvTLuSO+aY/k= | ||
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= | ||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= | ||
github.com/jdxcode/netrc v0.0.0-20180207092346-e1a19c977509 h1:G91xmBQ9Jntm4Dqgb0BGXMRipGBiYLYNWeKcbeJTXPk= | ||
github.com/jdxcode/netrc v0.0.0-20180207092346-e1a19c977509/go.mod h1:PSWm5RA4GUQ+cyCXiBIIUjlDWdJci5cU3GVKwaQRmW8= | ||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= | ||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= | ||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= | ||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= | ||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= | ||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= | ||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= | ||
github.com/vmihailenco/msgpack v4.0.0+incompatible h1:R/ftCULcY/r0SLpalySUSd8QV4fVABi/h0D/IjlYJzg= | ||
github.com/vmihailenco/msgpack v4.0.0+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= | ||
go.etcd.io/bbolt v1.3.0 h1:oY10fI923Q5pVCVt1GBTZMn8LHo5M+RCInFpeMnV4QI= | ||
go.etcd.io/bbolt v1.3.0/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= | ||
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= | ||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= | ||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= | ||
golang.org/x/net v0.0.0-20180921000356-2f5d2388922f h1:QM2QVxvDoW9PFSPp/zy9FgxJLfaWTZlS61KEPtBwacM= | ||
golang.org/x/net v0.0.0-20180921000356-2f5d2388922f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= | ||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= | ||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= | ||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= | ||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
golang.org/x/sys v0.0.0-20180824143301-4910a1d54f87/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20180921163948-d47a0f339242 h1:5DYsa+ZAwcJHjuY0Qet390sUr7qwkpnRsUNjddyc0b8= | ||
golang.org/x/sys v0.0.0-20180921163948-d47a0f339242/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= | ||
google.golang.org/appengine v1.2.0 h1:S0iUepdCWODXRvtE+gcRDd15L+k+k1AiHlMiMjefH24= | ||
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= | ||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= | ||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"os/exec" | ||
"sync" | ||
|
||
"github.com/gkze/stars/starmanager" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
func main() { | ||
sm, err := starmanager.New() | ||
if err != nil { | ||
log.Printf("Error creating StarManager! %v", err.Error()) | ||
} | ||
|
||
cmdline := cli.NewApp() | ||
cmdline.Name = "stars" | ||
cmdline.Usage = "Command-line interface to YOUR GitHub stars" | ||
cmdline.Commands = []cli.Command{ | ||
{ | ||
Name: "save", | ||
Usage: "Save all stars", | ||
Action: func(c *cli.Context) error { | ||
sm.SaveAllStars() | ||
|
||
return nil | ||
}, | ||
}, | ||
{ | ||
Name: "list-topics", | ||
Usage: "list all topics of starred projects", | ||
Action: func(c *cli.Context) error { | ||
sm.SaveIfEmpty() | ||
for _, t := range sm.GetTopics() { | ||
fmt.Println(t) | ||
} | ||
|
||
return nil | ||
}, | ||
}, | ||
{ | ||
Name: "random", | ||
Usage: "Browse random stars", | ||
Flags: []cli.Flag{ | ||
cli.IntFlag{ | ||
Name: "count, c", | ||
Value: 6, | ||
Usage: "Number of random stars to browse", | ||
}, | ||
cli.StringFlag{ | ||
Name: "language, l", | ||
Usage: "Limit to projects written only in this language", | ||
}, | ||
cli.StringFlag{ | ||
Name: "topic, t", | ||
Usage: "Limit to projects with this topic", | ||
}, | ||
}, | ||
Action: func(c *cli.Context) error { | ||
sm.SaveIfEmpty() | ||
stars, err := sm.GetRandomProjects(c.Int("count"), c.String("languaage"), c.String("topic")) | ||
if err != nil { | ||
log.Printf(err.Error()) | ||
} | ||
|
||
wg := sync.WaitGroup{} | ||
for _, proj := range stars { | ||
wg.Add(1) | ||
go func(p starmanager.Star) { | ||
defer wg.Done() | ||
cmd := exec.Command("/usr/bin/open", p.URL) | ||
err := cmd.Run() | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
}(proj) | ||
} | ||
wg.Wait() | ||
|
||
return nil | ||
}, | ||
}, | ||
{ | ||
Name: "clear", | ||
Usage: "Clear local stars cache", | ||
Action: func(c *cli.Context) error { | ||
if err := sm.ClearCache(); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}, | ||
}, | ||
{ | ||
Name: "cleanup", | ||
Usage: "Clean up old stars", | ||
Flags: []cli.Flag{ | ||
cli.IntFlag{ | ||
Name: "months, m", | ||
Value: 2, | ||
Usage: "Number of months to delete projects older than", | ||
}, | ||
}, | ||
Action: func(c *cli.Context) error { | ||
sm.SaveIfEmpty() | ||
if err := sm.RemoveOlderThan(c.Int("months")); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}, | ||
}, | ||
} | ||
|
||
cmdline.Run(os.Args) | ||
} |
Oops, something went wrong.