Skip to content

Commit a0659df

Browse files
committed
upgrade warg, add homepage link
1 parent be39b54 commit a0659df

8 files changed

+154
-49
lines changed

format.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"time"
1616

1717
"github.com/lestrrat-go/strftime"
18-
"go.bbkane.com/warg/flag"
18+
"go.bbkane.com/warg/command"
1919
_ "modernc.org/sqlite"
2020
)
2121

@@ -602,14 +602,14 @@ func (d *formattedDate) FormatString() (string, error) {
602602
return d.Format.FormatString(t), nil
603603
}
604604

605-
func format(pf flag.PassedFlags) error {
606-
format := pf["--format"].(string)
607-
includeReadmes := pf["--include-readmes"].(bool)
608-
maxLineSize := pf["--max-line-size"].(int)
609-
sqliteDSN := pf["--sqlite-dsn"].(string)
610-
zincIndexName := pf["--zinc-index-name"].(string)
605+
func format(ctx command.Context) error {
606+
format := ctx.Flags["--format"].(string)
607+
includeReadmes := ctx.Flags["--include-readmes"].(bool)
608+
maxLineSize := ctx.Flags["--max-line-size"].(int)
609+
sqliteDSN := ctx.Flags["--sqlite-dsn"].(string)
610+
zincIndexName := ctx.Flags["--zinc-index-name"].(string)
611611

612-
dateFormatStr, dateFormatStrExists := pf["--date-format"].(string)
612+
dateFormatStr, dateFormatStrExists := ctx.Flags["--date-format"].(string)
613613
var dateFormat *strftime.Strftime
614614
var err error
615615
if dateFormatStrExists {
@@ -619,7 +619,7 @@ func format(pf flag.PassedFlags) error {
619619
}
620620
}
621621

622-
output, outputExists := pf["--output"].(string)
622+
output, outputExists := ctx.Flags["--output"].(string)
623623
outputFp := os.Stdout
624624
if outputExists {
625625
newFP, err := os.Create(output)
@@ -658,7 +658,7 @@ func format(pf flag.PassedFlags) error {
658658
}
659659

660660
// https://stackoverflow.com/a/16615559/2958070
661-
input := pf["--input"].(string)
661+
input := ctx.Flags["--input"].(string)
662662
inputFp, err := os.Open(input)
663663
if err != nil {
664664
return fmt.Errorf("file open err: %w", err)

github.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"time"
1010

1111
"github.com/shurcooL/githubv4"
12-
"go.bbkane.com/warg/flag"
12+
"go.bbkane.com/warg/command"
1313
"golang.org/x/oauth2"
1414
)
1515

@@ -59,22 +59,22 @@ type Query struct {
5959
}
6060
}
6161

62-
func githubStarsDownload(pf flag.PassedFlags) error {
63-
token := pf["--token"].(string)
64-
pageSize := pf["--page-size"].(int)
65-
maxPages := pf["--max-pages"].(int)
66-
timeout := pf["--timeout"].(time.Duration)
67-
includeReadmes := pf["--include-readmes"].(bool)
68-
maxLanguages := pf["--max-languages"].(int)
69-
maxRepoTopics := pf["--max-repo-topics"].(int)
62+
func githubStarsDownload(ctx command.Context) error {
63+
token := ctx.Flags["--token"].(string)
64+
pageSize := ctx.Flags["--page-size"].(int)
65+
maxPages := ctx.Flags["--max-pages"].(int)
66+
timeout := ctx.Flags["--timeout"].(time.Duration)
67+
includeReadmes := ctx.Flags["--include-readmes"].(bool)
68+
maxLanguages := ctx.Flags["--max-languages"].(int)
69+
maxRepoTopics := ctx.Flags["--max-repo-topics"].(int)
7070

7171
var afterPtr *string = nil
72-
afterStr, afterExists := pf["--after-cursor"].(string)
72+
afterStr, afterExists := ctx.Flags["--after-cursor"].(string)
7373
if afterExists {
7474
afterPtr = &afterStr
7575
}
7676

77-
outputPath := pf["--output"].(string)
77+
outputPath := ctx.Flags["--output"].(string)
7878
// https://pkg.go.dev/os?utm_source=gopls#pkg-constants
7979
// return error if the file exists - NOTE: this kind of screws with any plans to append
8080
fp, err := os.OpenFile(outputPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0666)
@@ -86,12 +86,12 @@ func githubStarsDownload(pf flag.PassedFlags) error {
8686
buf := bufio.NewWriter(fp)
8787
defer buf.Flush()
8888

89-
ctx, cancel := context.WithTimeout(context.Background(), timeout)
89+
timeCtx, cancel := context.WithTimeout(context.Background(), timeout)
9090
defer cancel()
9191
src := oauth2.StaticTokenSource(
9292
&oauth2.Token{AccessToken: token},
9393
)
94-
httpClient := oauth2.NewClient(ctx, src)
94+
httpClient := oauth2.NewClient(timeCtx, src)
9595
client := githubv4.NewClient(httpClient)
9696

9797
var query Query
@@ -105,7 +105,7 @@ func githubStarsDownload(pf flag.PassedFlags) error {
105105
}
106106

107107
for i := 0; i < maxPages; i++ {
108-
err := client.Query(ctx, &query, variables)
108+
err := client.Query(timeCtx, &query, variables)
109109
if err != nil {
110110
return fmt.Errorf(
111111
"afterToken: %v , query err: %w",

go.mod

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ go 1.17
88
require (
99
github.com/lestrrat-go/strftime v1.0.5
1010
github.com/shurcooL/githubv4 v0.0.0-20211117020012-5800b9de5b8b
11-
go.bbkane.com/warg v0.0.13
11+
go.bbkane.com/warg v0.0.15
1212
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
1313
google.golang.org/api v0.62.0
1414
modernc.org/sqlite v1.14.5
@@ -27,11 +27,12 @@ require (
2727
github.com/pkg/errors v0.8.1 // indirect
2828
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
2929
github.com/shurcooL/graphql v0.0.0-20200928012149-18c5c3165e3a // indirect
30+
github.com/xhit/go-str2duration/v2 v2.0.0 // indirect
3031
go.bbkane.com/gocolor v0.0.4 // indirect
3132
go.opencensus.io v0.23.0 // indirect
3233
golang.org/x/mod v0.4.2 // indirect
3334
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420 // indirect
34-
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
35+
golang.org/x/sys v0.0.0-20220608164250-635b8c9b7f68 // indirect
3536
golang.org/x/text v0.3.6 // indirect
3637
golang.org/x/tools v0.1.5 // indirect
3738
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect

go.sum

+20-8
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
4949
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
5050
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
5151
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
52+
github.com/alecthomas/assert v1.0.0 h1:3XmGh/PSuLzDbK3W2gUbRXwgW5lqPkuqvRgeQ30FI5o=
53+
github.com/alecthomas/assert v1.0.0/go.mod h1:va/d2JC+M7F6s+80kl/R3G7FUiW6JzUO+hPhLyJ36ZY=
54+
github.com/alecthomas/colour v0.1.0 h1:nOE9rJm6dsZ66RGWYSFrXw461ZIt9A6+nHgL7FRrDUk=
55+
github.com/alecthomas/colour v0.1.0/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
56+
github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
57+
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae h1:zzGwJfFlFGD94CyyYwCJeSuD32Gj9GTaSi5y9hoVzdY=
58+
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
5259
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
5360
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
5461
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
@@ -185,6 +192,8 @@ github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6O
185192
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
186193
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
187194
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
195+
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
196+
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
188197
github.com/shurcooL/githubv4 v0.0.0-20211117020012-5800b9de5b8b h1:SAQLigkf0rd6emglkR1lRKRB9coWjib5OxnHmV1ZiFs=
189198
github.com/shurcooL/githubv4 v0.0.0-20211117020012-5800b9de5b8b/go.mod h1:hAF0iLZy4td2EX+/8Tw+4nodhlMrwN3HupfaXj3zkGo=
190199
github.com/shurcooL/graphql v0.0.0-20200928012149-18c5c3165e3a h1:KikTa6HtAK8cS1qjvUvvq4QO21QnwC+EfvB+OAuZ/ZU=
@@ -195,19 +204,19 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
195204
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
196205
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
197206
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
198-
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
199-
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
207+
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
208+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
209+
github.com/xhit/go-str2duration/v2 v2.0.0 h1:uFtk6FWB375bP7ewQl+/1wBcn840GPhnySOdcz/okPE=
210+
github.com/xhit/go-str2duration/v2 v2.0.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
200211
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
201212
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
202213
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
203214
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
204215
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
205216
go.bbkane.com/gocolor v0.0.4 h1:UI4ejgjHdC6oupH8src8+FQgbbfcZ6C7BSPZzecBjzs=
206217
go.bbkane.com/gocolor v0.0.4/go.mod h1:7AEOm8kyPlpj9qr/SL9mEXSceh8xM2w+eBm4deMRNHk=
207-
go.bbkane.com/warg v0.0.12 h1:+Jwf70ey/dlPCDmEREJSd045p1eGTX7r482bT2v3Cwc=
208-
go.bbkane.com/warg v0.0.12/go.mod h1:kfv+iD8YFvnpqv9bUR2zp1PYTHHJWesIikcRcuJTgIc=
209-
go.bbkane.com/warg v0.0.13 h1:BlnLM/gvELYqMpgAlAZCHLDJXKq1/uXKx1tLa+NtqXA=
210-
go.bbkane.com/warg v0.0.13/go.mod h1:kfv+iD8YFvnpqv9bUR2zp1PYTHHJWesIikcRcuJTgIc=
218+
go.bbkane.com/warg v0.0.15 h1:rRD9x4yoent7Ngq9eUiK28TeQbonx6k9MYH/ZJWQFJA=
219+
go.bbkane.com/warg v0.0.15/go.mod h1:QaSFzxmNkz6krxg8yKnCp4yAQPH6GuIWGQCVU0e6ByU=
211220
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
212221
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
213222
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
@@ -374,8 +383,9 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBc
374383
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
375384
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
376385
golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
377-
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=
378-
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
386+
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
387+
golang.org/x/sys v0.0.0-20220608164250-635b8c9b7f68 h1:z8Hj/bl9cOV2grsOpEaQFUaly0JWN3i97mo3jXKJNp0=
388+
golang.org/x/sys v0.0.0-20220608164250-635b8c9b7f68/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
379389
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
380390
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
381391
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -592,9 +602,11 @@ google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+Rur
592602
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
593603
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
594604
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
605+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
595606
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
596607
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
597608
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
609+
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
598610
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
599611
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
600612
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=

gsheets.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import (
88
"runtime"
99
"time"
1010

11-
"go.bbkane.com/warg/flag"
11+
"go.bbkane.com/warg/command"
1212
"golang.org/x/oauth2/google"
1313
"google.golang.org/api/option"
1414
"google.golang.org/api/sheets/v4"
1515
)
1616

17-
func gSheetsOpen(pf flag.PassedFlags) error {
18-
spreadsheetId := pf["--spreadsheet-id"].(string)
19-
sheetID := pf["--sheet-id"].(int)
17+
func gSheetsOpen(ctx command.Context) error {
18+
spreadsheetId := ctx.Flags["--spreadsheet-id"].(string)
19+
sheetID := ctx.Flags["--sheet-id"].(int)
2020

2121
link := fmt.Sprintf(
2222
"https://docs.google.com/spreadsheets/d/%s/edit#gid=%d",
@@ -43,12 +43,12 @@ func gSheetsOpen(pf flag.PassedFlags) error {
4343
return nil
4444
}
4545

46-
func gSheetsUpload(pf flag.PassedFlags) error {
47-
csvPath := pf["--csv-path"].(string)
48-
spreadsheetId := pf["--spreadsheet-id"].(string)
49-
sheetID := pf["--sheet-id"].(int)
50-
timeout := pf["--timeout"].(time.Duration)
51-
ctx, cancel := context.WithTimeout(context.Background(), timeout)
46+
func gSheetsUpload(ctx command.Context) error {
47+
csvPath := ctx.Flags["--csv-path"].(string)
48+
spreadsheetId := ctx.Flags["--spreadsheet-id"].(string)
49+
sheetID := ctx.Flags["--sheet-id"].(int)
50+
timeout := ctx.Flags["--timeout"].(time.Duration)
51+
timeCtx, cancel := context.WithTimeout(context.Background(), timeout)
5252
defer cancel()
5353

5454
csvBytes, err := ioutil.ReadFile(csvPath)
@@ -57,12 +57,12 @@ func gSheetsUpload(pf flag.PassedFlags) error {
5757
}
5858
csvStr := string(csvBytes)
5959

60-
creds, err := google.FindDefaultCredentials(ctx, sheets.SpreadsheetsScope)
60+
creds, err := google.FindDefaultCredentials(timeCtx, sheets.SpreadsheetsScope)
6161
if err != nil {
6262
return fmt.Errorf("can't find default credentials: %w", err)
6363
}
6464

65-
srv, err := sheets.NewService(ctx, option.WithCredentials(creds))
65+
srv, err := sheets.NewService(timeCtx, option.WithCredentials(creds))
6666
if err != nil {
6767
return fmt.Errorf("unable to retrieve Sheets client: %w", err)
6868
}
@@ -101,7 +101,7 @@ func gSheetsUpload(pf flag.PassedFlags) error {
101101
resp, err := srv.Spreadsheets.BatchUpdate(
102102
spreadsheetId,
103103
rb,
104-
).Context(ctx).Do()
104+
).Context(timeCtx).Do()
105105
if err != nil {
106106
return fmt.Errorf("batch error failure: %w", err)
107107
}

main.go

+2
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ func app() *warg.App {
171171
)
172172

173173
app := warg.New(
174+
"starghaze",
174175
section.New(
175176
"Save GitHub Starred Repos",
176177
section.Command(
@@ -190,6 +191,7 @@ func app() *warg.App {
190191
"gsheets",
191192
gsheetsSection,
192193
),
194+
section.Footer("Homepage: https://github.com/bbkane/starghaze"),
193195
),
194196
warg.SkipValidation(),
195197
)

queries.md

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
Interrogating my data!
2+
3+
# 10 most popular languages by repo
4+
5+
```bash
6+
$ sqlite3 starghaze.db '
7+
SELECT
8+
l.Name ,
9+
COUNT(lr.Language_id) as Repo_Count
10+
FROM
11+
Language_Repo lr JOIN Language l ON lr.Language_id = l.id
12+
GROUP BY Language_id
13+
ORDER BY Repo_Count DESC
14+
LIMIT 10
15+
'
16+
-- Loading resources from /Users/bbkane/.sqliterc
17+
┌────────────┬────────────┐
18+
│ Name │ Repo_Count │
19+
├────────────┼────────────┤
20+
│ Shell │ 939 │
21+
│ JavaScript │ 617 │
22+
│ HTML │ 598 │
23+
│ Python │ 540 │
24+
│ Makefile │ 519 │
25+
│ CSS │ 432 │
26+
│ Dockerfile │ 403 │
27+
│ Go │ 367 │
28+
│ C │ 305 │
29+
│ C++ │ 230 │
30+
└────────────┴────────────┘
31+
```
32+
33+
# 10 most popular languages by lines
34+
35+
Note that these are lines in the repo, which includes generated code
36+
37+
```
38+
starghaze.db> SELECT l.Name language_name, SUM(lr.Size) AS lines FROM `Language` l JOIN `Language_Repo` lr ON l.id = lr.`Language_id` GROUP BY l.`Name` ORDER BY lines DESC LIMIT 10;
39+
language_name lines
40+
C++ 942739556
41+
Jupyter Notebook 804633765
42+
Python 518129708
43+
C 442379463
44+
Go 366579078
45+
TypeScript 323614022
46+
JavaScript 319470060
47+
Java 306837166
48+
HTML 196157314
49+
C# 193605672
50+
```
51+
52+
# What Repo has the most C++ code?
53+
54+
```
55+
starghaze.db> SELECT l.Name AS language_name, lr.Size, "https://github.com/" || r.NameWithOwner AS link FROM `Language` l JOIN `Language_Repo` lr ON l.id = lr.`Language_id` JOIN Repo r ON lr.`Repo_id` = r.id WHERE l.`Name` = 'C++' ORDER BY lr.`Size` DESC LIMIT 10;
56+
language_name Size link
57+
C++ 119581200 https://github.com/bloomberg/bde
58+
C++ 89578048 https://github.com/microsoft/service-fabric
59+
C++ 57547160 https://github.com/duckdb/duckdb
60+
C++ 40643968 https://github.com/mapsme/omim
61+
C++ 36784149 https://github.com/godotengine/godot
62+
C++ 31984347 https://github.com/arangodb/arangodb
63+
C++ 29233152 https://github.com/vespa-engine/vespa
64+
C++ 23346282 https://github.com/organicmaps/organicmaps
65+
C++ 23113037 https://github.com/SerenityOS/serenity
66+
C++ 20847917 https://github.com/Z3Prover/z3
67+
10 rows in set
68+
``````
69+
70+
# How Many Repos do I star per month
71+
72+
```
73+
$ sqlite3 -cmd '.mode tabs' starghaze.db '
74+
SELECT strftime("%Y-%m", r.StarredAt) as month, COUNT(r.NameWithOwner) as [count] FROM `Repo` r GROUP BY month ORDER BY month ASC;
75+
' | tablegraph --firstline timechart
76+
```
77+
78+
# How have my topics changed over time?
79+
80+
Let's see count by topic by month? Something like:
81+
82+
2020-01 C++ 0
83+
2020-02 C++ 10
84+
2020-02 Python 10
85+
86+
```
87+
starghaze.db> SELECT strftime("%Y-%m", r.StarredAt) as month , l.Name, COUNT(r.NameWithOwner) as name_count FROM `Repo` r JOIN `
88+
Language_Repo` lr ON r.id = lr.`Repo_id` JOIN `Language` l ON lr.`Language_id` = l.id GROUP BY month ORDER BY mont
89+
h ASC;
90+
```

version.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"runtime/debug"
66

7-
"go.bbkane.com/warg/flag"
7+
"go.bbkane.com/warg/command"
88
)
99

1010
// This will be overriden by goreleaser
@@ -23,7 +23,7 @@ func getVersion() string {
2323
return version
2424
}
2525

26-
func printVersion(_ flag.PassedFlags) error {
26+
func printVersion(ctx command.Context) error {
2727
fmt.Println(getVersion())
2828
return nil
2929
}

0 commit comments

Comments
 (0)